一页适合所有人吗? [英] One page fits all?

查看:66
本文介绍了一页适合所有人吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有两个问题.首先,我希望能够从一个PHP页面显示整个网站,该页面根据浏览器传递的变量提供不同的部分.例如,您在主页"页面上,然后单击与我们联系".我希望原始页面也提供新页面的信息,而不是创建五个做不同的事情的不同页面.

所以问题是,如何通过URL链接传递变量,该变量告诉页面使用不同的参数重新加载自身?

第二个问题是,这是一个好主意吗?我什至不确定这是否是个好主意.与为网站上的每个页面创建一个不同的页面相比,以这种方式进行的利弊是什么?我只是从PHP开始,所以我的经验有限.

在此先感谢您.

Two questions here. First, I want to be able to display an entire website from one PHP page, with the page serving different sections depending on a variable passed from the browser. For example, you''re on the "Home" page, and you click "Contact us". I want the original page to also serve the info for the new page instead of creating five different pages doing five different things.

So the question is, how do you pass a variable through a URL link that tells the page reload itself with different parameters?

And the second question is, is this a good idea? I''m not even sure if this is a good idea. What are the pros and cons to doing it this way versus creating a different page for every page on the site? I''m just starting with PHP, so my experience is limited.

Thanks in advance.

推荐答案

我不是PHP人士,并且只有一点PHP经验,但是:

可以将全部路由到一页. MVC [ http://anantgarg.com /2009/03/13/write-your-own-php-mvc-framework-part-1/ [
I''m not a PHP person, and have only a little PHP experience but:

It is possible to route it all through one page. A well-established pattern to help do this is MVC[^]. There are good MVC frameworks out there apparently (Google "PHP MVC"). Or you can write your own http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/[^] if you really want to get to grips with this as a problem.

You can use query strings in the URL to pass information, or create generated JavaScripts to server up the correct view and do stuff.

To your second question, it is matter of horses-for-courses. If you just want several pages with different content, then I''d answer no. If you have lots of process-specific stuff (like Wizards) where the MVC pattern is a good fit, or you are just doing it to see how it would work, then I''d say yes.


这篇关于一页适合所有人吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆