ballhogjoni Posted June 18, 2007 Share Posted June 18, 2007 Is it possible to write and if () elseif () else () that you can compare the url in the browser address bar. example: if (http://xxx.com == http://xxx.com) { // some code } elseif (http://xxxx.com == http://xxxx.com) { //some code } and so... Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/ Share on other sites More sharing options...
per1os Posted June 18, 2007 Share Posted June 18, 2007 Confused? <?php $check = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($check == "http://www.youriste.com/x.html") { }elseif ($check == "http://www.youriste.com/x.html") { }else { } ?> Like that? Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276848 Share on other sites More sharing options...
ballhogjoni Posted June 18, 2007 Author Share Posted June 18, 2007 I think that sounds right let me play wiith it and get back to you. Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276851 Share on other sites More sharing options...
ballhogjoni Posted June 18, 2007 Author Share Posted June 18, 2007 Ok that didn't work. How would I echo the current URL and paste that in the page. Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276854 Share on other sites More sharing options...
ballhogjoni Posted June 18, 2007 Author Share Posted June 18, 2007 Ok never mind on my last post. I was able to post the current url...but I would like for it to jsut print the main url and the sub folder not the actual html, php file. example: http://file.com/sub_folder instead of http://file.com/sub_folder/index.php Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276857 Share on other sites More sharing options...
per1os Posted June 18, 2007 Share Posted June 18, 2007 www.php.net/pathinfo <?php $path_parts = pathinfo($_SERVER['REQUEST_URI']); $check = "http://" . $_SERVER['SERVER_NAME'] . $path_parts['dirname']; ?> See if that suits your needs. Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276859 Share on other sites More sharing options...
ballhogjoni Posted June 18, 2007 Author Share Posted June 18, 2007 Thx I appreciate that. for some reason it din't work. I am trying to figure out why becasue I echoed the . $_SERVER['SERVER_NAME'] . $path_parts['dirname'] and it printed correctly for the page I am on, but my if statement is saying that its not equal to url path. Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276869 Share on other sites More sharing options...
ballhogjoni Posted June 18, 2007 Author Share Posted June 18, 2007 Ok, I missed the fact that I had a closing / in my if statement but not in the variable I was comparing. So i got it figured out. Thank for your help. Link to comment https://forums.phpfreaks.com/topic/56058-solved-is-it-possible-to-do-this/#findComment-276875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.