doubledee Posted July 9, 2011 Share Posted July 9, 2011 I want to find the file name of the current web page. I have this code but it gives me the whole path from the web root... <?php $page = substr($_SERVER['REQUEST_URI'], 1); if ($page == '/') { $page = "index.php"; } echo 'page = ' . $page; ?> Debbie Quote Link to comment https://forums.phpfreaks.com/topic/241515-need-to-get-file-name/ Share on other sites More sharing options...
QuickOldCar Posted July 9, 2011 Share Posted July 9, 2011 <?php $current_page = basename($_SERVER['REQUEST_URI']); if (strpos($current_page, "?") !== false){ $current_page = reset(explode("?", $current_page)); } echo $current_page; ?> Quote Link to comment https://forums.phpfreaks.com/topic/241515-need-to-get-file-name/#findComment-1240597 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.