index.php?somevar=somepage linking
Moderator: General Moderators
index.php?somevar=somepage linking
i asked a similar question in another thread, but that one had another question initially so i decided to re-ask here.
having in mind that a site has a fixed number of pages of a similar layout (with different content of course), is //index.php?somevar=somepage kind of linking acceptable? if i use //somepage.php linking, i save one function (which is used to include 'somepage' based on $somevar value if using query string) and the link looks 'cleaner', but i get quite a bit of repetitive identical layout code on each somepage.php as well as additional files (to store ONLY the content code for the sake of my own convenience, each of them included in a corresponding somepage.php). in my previous thread i was explained that it's a bad design to use query strings for static stuff which seems logical. however, there are lots of tutorials explaining how to use query strings for simple static page navigation on the net (even zend.com has one). do you find this kind of linking normal for accessing static content? do you use it? why/why not? opinions and explanations are very welcome.
having in mind that a site has a fixed number of pages of a similar layout (with different content of course), is //index.php?somevar=somepage kind of linking acceptable? if i use //somepage.php linking, i save one function (which is used to include 'somepage' based on $somevar value if using query string) and the link looks 'cleaner', but i get quite a bit of repetitive identical layout code on each somepage.php as well as additional files (to store ONLY the content code for the sake of my own convenience, each of them included in a corresponding somepage.php). in my previous thread i was explained that it's a bad design to use query strings for static stuff which seems logical. however, there are lots of tutorials explaining how to use query strings for simple static page navigation on the net (even zend.com has one). do you find this kind of linking normal for accessing static content? do you use it? why/why not? opinions and explanations are very welcome.
I don't usually use query strings for static navigation. I mean, it doesn't hurt anything... but if you can avoid it, why would you?
There's an exception though that I use. I have a 'fun' page which has different sections, games, puzzles, adlibs, videos, pictures, etc. I use a query string to determine the section. That's about it though.
I would exactly say it's bad practice as it can get you familiar with using query strings and using $_GET. But I avoid it whenever possible.
There's an exception though that I use. I have a 'fun' page which has different sections, games, puzzles, adlibs, videos, pictures, etc. I use a query string to determine the section. That's about it though.
I would exactly say it's bad practice as it can get you familiar with using query strings and using $_GET. But I avoid it whenever possible.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
i use the index.php?u=page when i am kinda useing a iframe but without the iframe. it works just fine if you do a little bit of security first. i have heard many people bash it but i dont understand why, it saves time by not having to edit a billion different pages over a simple design change and its easy to manage plus the code is usually seperated because the index.php page is mostly html and the included pages are your code so it makes life that much easier.
It may sound like I'm splitting hairs here, but...
I personally detest somepage.php?page=foo, but I like somepage/foo, where somepage is a PHP script (using a ForceType directive in Apache).
You often see this style on sites that do like
etc.
The "Design" and "CoolScripts" directory may not really exist, and their faking it via the ForceType and "look-back" chaining. Once they find the "articles" script, it explodes the following "directories" and then uses those to setup the needed variables, in that sense its exactly like ?area=onething&article=foo query string, but doesn't look at ugly
. It also seperates true query string behavoir from "navigation"/"filesystem abstraction" uses.
I personally detest somepage.php?page=foo, but I like somepage/foo, where somepage is a PHP script (using a ForceType directive in Apache).
You often see this style on sites that do like
Code: Select all
http://domain/articles/Design/CoolDesign
http://domain/articles/CoolScripts/FooiliciousScriptThe "Design" and "CoolScripts" directory may not really exist, and their faking it via the ForceType and "look-back" chaining. Once they find the "articles" script, it explodes the following "directories" and then uses those to setup the needed variables, in that sense its exactly like ?area=onething&article=foo query string, but doesn't look at ugly
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
On every single one of my pages I probably use an index which loads pages depending on the query string. I greatly benefit from this as I can control which users, depending on their user priviliges/permissions, can view which page -- and just as easily restrict pages. The list goes on and on, and I know this is all possible through other methods, I just find it seemingly easier to control things when they are all funnelled through 1 spot (index).
I tend to "funnel" everything thought my "master include"
ie every script starts
include_others.inc does permissions checks, logging, some minor URL parsing to determine which block of other classes to include, etc.
Everything stills goes through one place, but its not overloading a single page. (It also plays nicer with most off-the-shelf apache-log stats packages.)
ie every script starts
Code: Select all
require_once("include_others.inc");Everything stills goes through one place, but its not overloading a single page. (It also plays nicer with most off-the-shelf apache-log stats packages.)
I find if I am going to include a file based on a query string, I use mod_rewrite, it [the url] looks much more "friendly" to the end user which I think is more important then how easy it is for the developer, the easier it is for some one to remember or type your url, the more likely that user is to re-visit that page, or spread your web site via word of mouth.
Hi All
I am a newbie to PHP and have just started out on a large project. It has a demo version that has the index.php?page=somepage format.
I read the earlier posts but am still not clear if it is definitely a good idea to do this instead of using a direct link to the desired page.
Could somebody help me and explain which to follow?
Thanks and Regards
I am a newbie to PHP and have just started out on a large project. It has a demo version that has the index.php?page=somepage format.
I read the earlier posts but am still not clear if it is definitely a good idea to do this instead of using a direct link to the desired page.
Could somebody help me and explain which to follow?
Thanks and Regards
I normally just make a page for each script and include a header file and footer file, but I'm starting to realise the benefits of doing it the other way round.
The main 'bonus' I can see to using index.php?pid=foo is you can have all the other pages with whatever extension you like and can then restrict all users to only be able to view .php extensions, thus forcing them to use index.php

The main 'bonus' I can see to using index.php?pid=foo is you can have all the other pages with whatever extension you like and can then restrict all users to only be able to view .php extensions, thus forcing them to use index.php
dittoJenk wrote:I normally just make a page for each script and include a header file and footer file
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Thanks for your replies. But what can one do if we want to pass querystrings? I have page where I am passing as
What do I do then?
Thanks and Regards
Code: Select all
abc.php?ownerid=1Thanks and Regards
On my site I have one main page that is loaded every time (index.php). Depending on what is passed the appropriate includes are loaded (which I have tons of). As this is all done in a OOP style where I seperate presentation, function, and data making the site very structured. As I have been building on this site for almost a year (it is modular so I keep adding to it) the is getting quite large, yet it is very easy for me to add an additional module and change existing ones without effecting other parts of the site. And if I have to change the style of the site I can do it in one place and it automatically changes the entire site.
So, for my structure, I do use the querystring to load static content and for searches.
So, for my structure, I do use the querystring to load static content and for searches.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: index.php?somevar=somepage linking
This is the problem that is solved by the Front Controller pattern, which is just a script that takes URL request with parameters like you specify and selects the appropriate response for it.Ree wrote: if i use //somepage.php linking, i save one function (which is used to include 'somepage' based on $somevar value if using query string) and the link looks 'cleaner', but i get quite a bit of repetitive identical layout code on each somepage.php as well as additional files (to store ONLY the content code for the sake of my own convenience, each of them included in a corresponding somepage.php).
I don't see why it is bad design to "use query strings for static stuff"? However it may be bad design to have duplicated code for the reason that you need to make changes to every duplicate. You may want to read about DRY (http://www.artima.com/intv/dry.html) to find out more about this design concept.Ree wrote:in my previous thread i was explained that it's a bad design to use query strings for static stuff which seems logical. however, there are lots of tutorials explaining how to use query strings for simple static page navigation on the net (even zend.com has one). do you find this kind of linking normal for accessing static content? do you use it? why/why not? opinions and explanations are very welcome.