Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中更改页面-重复html标记?_Php_Html - Fatal编程技术网

在php中更改页面-重复html标记?

在php中更改页面-重复html标记?,php,html,Php,Html,我正在学习php,我有一个非常简单的问题。我不确定如何处理我的网站中的多个页面 最简单的例子是index.php: <html> <head> <title>PHP example</title> <link rel="..."> <script src="..."></script> </head> <body>

我正在学习php,我有一个非常简单的问题。我不确定如何处理我的网站中的多个页面

最简单的例子是index.php:

<html>
    <head>
      <title>PHP example</title>
      <link rel="...">
      <script src="..."></script>
    </head>
    <body>
        ...
        <input type="button" value="View" onClick="window.location='view.php';" />
        ...
    </body>
</html>
据我所知,当用户单击按钮时,浏览器将重定向到view.php-因此该页面应该是一个完整的html页面,就像index.php包含所有相关标记一样

在新页面中重复所有html标记是否正确

我不是说替换div的内容,就像在菜单结构中,每个项都指向相关内容的单页应用程序一样。
在这种情况下,我真的需要替换整个正文内容,因此我想知道创建另一个完整的html页面是否正确。

是的,这是正确的方法,您需要为每个请求创建页面。直到您没有使用任何CMS或路由从数据库中获取每个请求的内容

php中有许多不同的框架,它们以许多不同的方式处理请求


但是,在设计网站的方式中,您必须为每个请求创建页面。您可以做的是创建一个公共文件,并要求为诸如页眉和页脚或左/右侧边栏(如果有)等公共元素创建一个公共文件。

更常见的方法是在它们自己的文件中包含任何共享元素页眉、页脚等,然后使用include或类似工具将其拉入页面本身。