allex01 Posted June 28, 2008 Share Posted June 28, 2008 Hi, If my page url look like http://domain.com/memebrs/page1.php?b=3................etc.. How can i grab just page1.php from the URL. I want to be able to set that as a varaible. example $page1="page1.php"; Another words i want to be able to grad the page file name that is just before the ? I appriciate your help. Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/ Share on other sites More sharing options...
LooieENG Posted June 28, 2008 Share Posted June 28, 2008 <?php $page1 = $_SERVER['PHP_SELF']; ?> I think Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576880 Share on other sites More sharing options...
allex01 Posted June 28, 2008 Author Share Posted June 28, 2008 Thanks LooieENG , I tried it. It outputs members/page1.php. I just want it grab page1.php. Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576928 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Share Posted June 28, 2008 $_SERVER['REQUEST_URI']; Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576935 Share on other sites More sharing options...
LooieENG Posted June 28, 2008 Share Posted June 28, 2008 <?php $url = explode('/', $_SERVER['PHP_SELF']); $page = $url[count($url) - 1]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576937 Share on other sites More sharing options...
allex01 Posted June 28, 2008 Author Share Posted June 28, 2008 Works great. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576959 Share on other sites More sharing options...
DeanWhitehouse Posted June 28, 2008 Share Posted June 28, 2008 which one. and click topic solved. please. Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-576962 Share on other sites More sharing options...
allex01 Posted June 29, 2008 Author Share Posted June 29, 2008 LooieENG solution works <?php $url = explode('/', $_SERVER['PHP_SELF']); $page = $url[count($url) - 1]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/112361-solved-grab-pagephp-from-url/#findComment-577009 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.