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

What does include mean in php

王林
Release: 2023-03-01 18:18:01
Original
5361 people have browsed it

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';
Copy after login

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;;
Copy after login

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 &#39;menu.php&#39;; ?>
</div>
<h1>欢迎来到我的主页!</h1>
<p>一些文本。</p>
</body>
</html>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template