Skip to main content
Home / Code Snippets / PHP / Get Current File Name

Get Current File Name

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

Potential use:

<body id="body_<?php echo $pageName; ?>">

Append ID to body to do different CSS styles on different pages.

icon-link icon-logo-star icon-search icon-star