PHP - Current Page Name


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. // Get the current page / file name and strip off the .php file type
  4. $current_page = basename($_SERVER[PHP_SELF], ".php");
  5.  
  6. // Check to see if the current page is called services and echo class
  7. echo ($current_page == 'services' ? 'class="current"' : '');
  8.  
  9. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.