Home >Backend Development >PHP Problem >How to call a page in php

How to call a page in php

藏色散人
藏色散人Original
2019-09-29 17:47:403137browse

How to call a page in php

#How to call a page in php?

In php, you can use the include statement to insert the contents of a PHP file into another PHP file (before the server executes it).

Note:

If you want to continue execution and output the results to the user even if the included file is missing, then use include. Otherwise, in frameworks, CMS, or complex PHP application programming, always use require to reference key files to the execution flow. This helps improve application security and integrity in the event that a critical file is accidentally lost.

Including files saves a lot of work. This means you can create standard header, footer or menu files for all pages. Then, when the header needs updating, you simply update the header include file.

include syntax

include 'filename';

PHP include example

Suppose we have a standard file named "footer.php" Footer file, like this:

<?php
echo "<p>Copyright © 2006-" . date("Y") . " W3School.com.cn</p>";
?>

If you need to reference this footer file in a page, please use the include statement:

<html>
<body>
<h1>欢迎访问我们的首页!</h1>
<p>一段文本。</p>
<p>一段文本。</p>
<?php include &#39;footer.php&#39;;?>
</body>
</html>

For more PHP knowledge, please visit PHP Chinese website!

The above is the detailed content of How to call a page 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