Home > Article > Backend Development > What does include mean in php
The include statement in php is used to insert useful code written in other files into the execution flow. The include statement generates a warning and the script continues execution after the error occurs. The syntax of the include statement is: [include 'filename'].
include
The include statement is used to insert useful code written in other files into the execution flow.
include generates a warning (E_WARNING) and the script will continue execution after the error occurs. Therefore, use include if you wish to continue execution and output results to the user even if the included file is missing.
Syntax:
include 'filename';
Example:
Suppose we have a standard menu file that is used in all pages.
"menu.php": echo '<a href="/">主页</a><a href="/html">HTML 教程</a><a href="/php">PHP 教程</a>';
All pages in the website should reference this menu file. The following is the specific approach:
<html> <head> <meta charset="utf-8"> <title>php中文网(www.php.cn/)</title> </head> <body> <div class="leftmenu"> <?php include 'menu.php'; ?> </div> <h1>欢迎来到我的主页!</h1> <p>一些文本。</p> </body> </html>
If you want to know more related issues, please visit php Chinese website.
The above is the detailed content of What does include mean in php. For more information, please follow other related articles on the PHP Chinese website!