Home >Backend Development >PHP Problem >What does include mean in php

What does include mean in php

王林
王林Original
2020-06-30 10:07:305313browse

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'].

What does include mean in php

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 &#39;<a href="/">主页</a><a href="/html">HTML 教程</a><a href="/php">PHP 教程</a>&#39;;

All pages in the website should reference this menu file. The following is the specific approach:

<html>
<head>
<meta charset="utf-8">
<title>php中文网(m.sbmmt.com/)</title>
</head>
<body>
<div class="leftmenu">
<?php include &#39;menu.php&#39;; ?>
</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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn