Home >Backend Development >PHP Problem >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 'footer.php';?> </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!