PHP noob question
- Started
- Last post
- 5 Responses
- frankosonik
I need to display different content on a page based on the URL, but without using a query string.
I know how to do the if/then/else statements, but I'm unsure of the exact syntax used to call the URL.
Thanks.
- connerd0
check http://php.net, i always find answers there when i'm stuck on simple syntax. look up url.
- unfittoprint0
content.php?var1=this&var2=that
and to retrieve the GET vars
foreach ($_GET as $key => $value) {
$$key = $value;
}
- frankosonik0
thanks for your responses.
Unfit --
I probably didn't make myself clear enough, but I don't want to use any query string at all, so the URLs will look like this:whatever.com/story/oct/15.php
not this:
whatever.com?sto=oct&day=15I want to be able to control what content is displayed based on the first URL example (friendlier URLs and easier to index).
- bcoden0
Ok it is pretty easy all you need to do is parse out the url with $_SERVER['PHP_SELF'] and then use the splt command to get the page name eg.
function PageName($page)
{
$PageName = split(".",$page)return $PageName;
}then
$PageName = PageName($_SERVER['PHP_SELF'])
try that out I hav not tested it so you mat need to do soem debugging but try that. you can alos msn me at
- bcoden0
Sorry about last post you would return $PageName[0]. It is an array that is being returned.