How to get current page name in PHP?

current page name

To get the current page URL that is shown in the browser URL window.

  • Want to make include file with a function
  • Create a link to the page itself
  • Variable added with an query string

Ex: You can now get the current page URL using the line: <?php echo curPageURL(); ?>

This is the method to return the current page file name. Using basename() function and $_SERVER['PHP_SELF'] variable you can get current page name.

<?php
echo basename($_SERVER['PHP_SELF']);
?>

Anu

Do you have anything to Ask?

This site uses Akismet to reduce spam. Learn how your comment data is processed.