- How to get current webpage file name with PHP.
- Custom PHP function get current page name.
Function returns the name of currently opened page.
Function
function getPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
Calling The Function
echo getPageName();
Output
login.php

Leave A comment
Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *