SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot yeszir's Avatar
    Join Date
    Sep 2003
    Location
    Boston
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional code based on file?

    What would the conditional be for a statement that calls a certain script only if it is not on a certain file on my site, for example it would only call the script if included on the /index.php as an example.

    Thanks!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($_SERVER['PHP_SELF'] == '/index.php') {
        
    // current file is index.php
    }

    // or
    if ($_SERVER['PHP_SELF'] != '/index.php') {
        
    // current file is NOT index.php
    }

    // see the other available vars
    print_r($_SERVER); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •