tqla Posted December 2, 2008 Share Posted December 2, 2008 I wish to have a page that will use includes to include text based on what's in the URL. Is it possible for PHP to read the URL? Sort of like this: <?php if ( $url == "?services" ) { <?php include("servicestext.php"); ?>"; }elseif ( $url == "?work" ){ <?php include("worktext.php"); ?>"; }elseif ( $url == "?travel" ){ <?php include("traveltext.php"); ?>"; } ?> How would I test the $url value? Thanks Link to comment https://forums.phpfreaks.com/topic/135212-solved-select-page-based-on-url/ Share on other sites More sharing options...
Maq Posted December 2, 2008 Share Posted December 2, 2008 I think you want to use the $_GET method. What does your URL look like? And why do you keep opening and closing PHP tags when all you're using is PHP? Ex: www.yoursite.com?your_var=services $url = $_GET['your_var']; if ($url == "services" ) { include("servicestext.php"); }elseif ( $url == "work" ) { include("worktext.php"); }elseif ( $url == "travel" ) { include("traveltext.php"); } Link to comment https://forums.phpfreaks.com/topic/135212-solved-select-page-based-on-url/#findComment-704234 Share on other sites More sharing options...
tqla Posted December 2, 2008 Author Share Posted December 2, 2008 Ooops. I just did the open and close tags out of habit while I was writing the post. Wow, that was bad. Thanks for correcting it. My URLS will look like this: http:// www . mysite . com / index?services (I put in the spaces so a link would not be created) Link to comment https://forums.phpfreaks.com/topic/135212-solved-select-page-based-on-url/#findComment-704239 Share on other sites More sharing options...
tqla Posted December 2, 2008 Author Share Posted December 2, 2008 in the code: $url = $_GET['your_var']; What should I replace "your_var" with to get the URL? Link to comment https://forums.phpfreaks.com/topic/135212-solved-select-page-based-on-url/#findComment-704265 Share on other sites More sharing options...
tqla Posted December 3, 2008 Author Share Posted December 3, 2008 Maq, sorry I did not notice you had answered my question the first time before I wrote the other two replies. Thank you!!!!! Link to comment https://forums.phpfreaks.com/topic/135212-solved-select-page-based-on-url/#findComment-704502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.