Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get current file name in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 157
    Comment on it

    Hello Readers if you getting in codition where you have to find the current file name then this blog is very helpful to you. Suppose you are making user redirect only when he is in account.php then you just have to fine the file name.

    <?php
    if ($currentPage == 'account.php')
    { 
    //do your code here..
    }
    
    ?>
    

    So get the file name you have to php syntax $_SERVER['PHP_SELF'], And the code will go like this:=

    <?php
      echo "My PHP file name is =". basename($_SERVER['PHP_SELF']); 
    
    ?>
    

    And here below is the screenshots of output.alt text

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: