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 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; ?> 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
Archived
This topic is now archived and is closed to further replies.