使用单个服务器端脚本页面还是多个无脚本页面?
我经常看到网站使用多个页面来显示其信息,而我一直更喜欢使用单个页面,通过 PHP 脚本自动更改其内容。只使用一个页面不是更快更简单吗?每次使用网页参数都会更改的页面,而不是具有相同布局的多个副本?
例如:
... <body> ... <?php insert_requested_content(); ?> ... </body> ...
应该比拥有一堆具有相同页眉、页脚、导航栏等的页面更简单。
当我创建网站时,我通常有一个index.php页面,然后是包含在索引中的内容页面.php 通过脚本,当它们被诸如这样的参数请求时:
http://mywebsite.com/?content=news
那么:为什么人们仍然使用许多不同的页面?是否有任何特殊需要这样做,或者这只是一个选择问题?
蜘蛛在尝试访问使用此设计创建的网站内容时是否会遇到任何困难?
I often see that websites use more than one page to display their information, while I've always preferred to use a single page which automatically changes its content by means of a PHP script.. Won't it be faster and simpler to have only one page that changes every time using a webpage argument, instead of having multiple copies of the same layout?
For instance:
... <body> ... <?php insert_requested_content(); ?> ... </body> ...
should be simpler than having a bunch of pages with the same header, footer, navbar, etc..
When I create a website, I usually have one index.php page and then the content pages, which are included into the index.php by the script, when they are requested by an argument such as:
http://mywebsite.com/?content=news
So: why people still use many different pages? Is there any particular need of doing this, or it's just a matter of choice?
Do spiders encounter any difficulties when trying to access the content of a website created with this design?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用多个页面来反映不同的内容,同时维护可以按照上面所述插入的通用页眉/页脚和 CSS,通常会使您的程序结构变得更容易。如果您的网站内容超过三页或四页,则将所有内容放在一个页面中并动态尝试确定用户请求的内容并正确显示它可能会成为 if/else 语句的噩梦。
Your program structure is usually made easier by having multiple pages to reflect your different content while maintaining a common header/footer and css that can be inserted as you stated above. Placing all of your content in one page and dynamically trying to determine what the user is requesting and display it properly can become a nightmare of if/else statements if your site gets much more than three or four pages of content.