Forum Moderators: coopster
I have the following PHP code that I use for navigation within my website.
<?php
If ($page==0) { include("page1.php");}
If ($page==1) { include"page2.php");}
?>
And my links are as follows :
<a href="index.php?page=0"> News </a>
<a href="index.php?page=1"> Links </a>
Could someone please tell me how to change this code so that I can use text values (I.e If ($page==news)) as I can't seem to get this to work.
Another couple of questions..
* Is this the standard way of doing website navigation?
* Will Google understand php navigation or will it think I only have one page?
Thanks again.
That should allow you to use the actuall name instead of the number. When ever you use works you have to put them in quotes either single or double depending on your coding style. I think there are some actually some valid reasons for useing certin ones at certin times but for what you are doing double or single will be fine.
The great thing about PHP and writing your own code there is no true standard way. I have designed sites this way and done it other ways. it all depends on what your doing and what you want to achive.
I have not had alot of issues with google grabing the names when they are small. There has been lots of debates on issues with varibles in urls and if I remember correctly you are ok if its not a whole slew and it seems to have problems with sessions IDs due to the length of them. It will think you have more than one page however it doesnt view it as one page since the content should be different on each page.
site.com/index.php?page=news
or
site.com/news/
Your visitors, however, might care and you might too. The second version has some major advantages
1. easier for people to say over the phone
2. easier to remember
3. won't change when technology changes
4. recommended by W3C
Search Google and WebmasterWorld (using Google) on "clean URLs" and "search engine friendly URLS" and "human readable URLs" and all of above using URI instead. Also look for Tim Berners-Lee article on "Cool URIs Don't Change"
Tom