simun Posted July 10, 2009 Share Posted July 10, 2009 how to get name of current page of url? exsample: if my url is www.mysite.com/files/images/page.php i wish to echo onley page.php from that,,, how to do it? Link to comment https://forums.phpfreaks.com/topic/165472-request-url/ Share on other sites More sharing options...
ignace Posted July 10, 2009 Share Posted July 10, 2009 <?php print basename($_SERVER['SCRIPT_NAME']); ?> Link to comment https://forums.phpfreaks.com/topic/165472-request-url/#findComment-872724 Share on other sites More sharing options...
simun Posted July 10, 2009 Author Share Posted July 10, 2009 and what if i have something like this: $putanja = "../files/naslovi/" . $_GET['id'] . "/" . $photo['filename'] . ".txt"; and i need that my variable $putanja echo onley . $photo['filename'] . ".txt" i have try $putanja = substr("../files/naslovi/" . $_GET['id'] . "/" . $photo['filename'] . ".txt", -20, -4); bote some times my id have 3 characters sometimes 1 character, and thats not good solution, Link to comment https://forums.phpfreaks.com/topic/165472-request-url/#findComment-872730 Share on other sites More sharing options...
niranjnn01 Posted July 10, 2009 Share Posted July 10, 2009 hello use $_SERVER['PHP_SELF'] Link to comment https://forums.phpfreaks.com/topic/165472-request-url/#findComment-872741 Share on other sites More sharing options...
ignace Posted July 10, 2009 Share Posted July 10, 2009 Then it would still work $putanja = "../files/naslovi/" . $_GET['id'] . "/" . $photo['filename'] . ".txt"; print basename($putanja); //$photo['filename'].txt Link to comment https://forums.phpfreaks.com/topic/165472-request-url/#findComment-872753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.