PlagueInfected Posted September 1, 2009 Author Share Posted September 1, 2009 still doesn't run my echo =[ Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-909984 Share on other sites More sharing options...
darkfreaks Posted September 1, 2009 Share Posted September 1, 2009 what does $page and $directory_no return when echoed Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-909996 Share on other sites More sharing options...
ShaunO Posted September 1, 2009 Share Posted September 1, 2009 Personally I would code it like this; <?php $filename = substr($_SERVER["SCRIPT_FILENAME"], strrpos($_SERVER["SCRIPT_FILENAME"], "/") + 1); switch($filename) { case "index.php": echo "Plague Infected | Index"; break; case "contact.php": echo "Plague Infected | Contact"; break; case "portfolio.php": echo "Plague Infected | Portfolio"; break; default: echo "Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico"; break; } ?> But that's just me anyway. Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910002 Share on other sites More sharing options...
PlagueInfected Posted September 1, 2009 Author Share Posted September 1, 2009 that didnt work either Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910317 Share on other sites More sharing options...
darkfreaks Posted September 1, 2009 Share Posted September 1, 2009 Josh, why dont you rewrite the page with pg= or p= like you did with the other things. then when you have done that output like so <title><?php echo $page;?> </title> <?php $page= $GET['pg']; switch($page) { case ($page=="index"); echo "Plague Infected | Index"; break; case($page=="seo"): echo "Plague Infected | Contact"; break; case ($page=="portfolio"): echo "Plague Infected | Portfolio"; break; default: echo "Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico"; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910383 Share on other sites More sharing options...
PlagueInfected Posted September 1, 2009 Author Share Posted September 1, 2009 it would only work on urls defined as 'http://mysite.com/?pg=seo" but what about for contact.php or portfolio.php Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910397 Share on other sites More sharing options...
ShaunO Posted September 2, 2009 Share Posted September 2, 2009 that didnt work either What is the full absolute URL that you are typing into the web browser? Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910665 Share on other sites More sharing options...
PlagueInfected Posted September 2, 2009 Author Share Posted September 2, 2009 i did http://plagueinfected.com http://plagueinfected.com/index.php?pg=index http://plagueinfected.com/contact.php http://plagueinfected.com/portfolio.php Quote Link to comment https://forums.phpfreaks.com/topic/172556-echo-text-based-on-the-url/page/2/#findComment-910717 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.