我希望使用 PHP 在多个页面中使用相同的 html shell,这样我只需要更改一个页面而不是多个页面。
显然只需要一行。
只需将您的许多 php 文件中多次使用的代码移动到单独的 php 文件中,并以三种方式使用
<?php include 'filename.php';?>//suppose not found then include will only produce a warning (E_WARNING) and the script will continue
<?php require 'filename.php';?>//suppose not found require will produce a fatal error (E_COMPILE_ERROR) and stop the script
<?php require_once 'filename.php'; ?>//include only once in whole same PHP file
我希望它清楚你......
您可以创建一个新文件并将所有 html 放入其中,然后将此代码添加到您希望拥有该文件内容的每个页面:
<?php require_once 'filename.php'; ?>