opel Posted November 6, 2006 Share Posted November 6, 2006 Still trying to learn some PHP and getting stuck again.I am trying to create a switch statement that looks at a URL and displays some HTML formated content. Below is what I have so far but I'm getting stuck on how to identify the URL as I have pages that start with the same word e.g news-list.php, news-detail.php and I would like the condition content to display for anything that starts "news".[code]<?phpswitch (condition) { case "header("Location: ../central/news");" :<p>This will be my content for the news section</p> break; case "header("Location: ../central/links");" :<p>This will be my content for the links section</p> break; default : <p>This will be my default message</p> break; }?>[/code]Thanks for any help or tips you can offer me. Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 6, 2006 Share Posted November 6, 2006 The header statement you're using will send the user to a NEW page://send user to www.mydomain.com/test.phpheader("Location: www.mydomain.com/test.php");You want to test against $_SERVER['php_self'] (that's the variable containing the URL of the current script file) and have a look at the following link:[url=http://www.php.net/eregi]www.php.net/eregi[/url] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.