Only show on index.php

Discussion in 'PHP' started by mgrohan, Jun 15, 2009.

  1. #1
    There is a div of content that I want to only have shown on the home page of my site. (index.php).

    Is there anyway to do this with php, based on the URL (index.php)?
     
    mgrohan, Jun 15, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    <?
    
    if(basename($_SERVER['PHP_SELF']) == "index.php") {
          ?>
              #create html elements here or maybe use function readfile
          <?
    }
    
    ?>
    Code (markup):
    include code in all files...
     
    Vooler, Jun 16, 2009 IP
    mgrohan likes this.
  3. emed

    emed Peon

    Messages:
    70
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this should work
    if(strtolower($_SERVER['SCRIPT_NAME'])=='/index.php'){
    //do stuff
    }
    PHP:
    (forgot to click submit >.<)
     
    emed, Jun 16, 2009 IP
    mgrohan likes this.
  4. mgrohan

    mgrohan Active Member

    Messages:
    671
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Thanks for the help! Rep added.
     
    mgrohan, Jun 16, 2009 IP