1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP (If..Else) Statement - Based On Filename

Discussion in 'PHP' started by LindseyInteractive, Apr 21, 2011.

  1. #1
    Hello Guys,

    I am not the best personally with PHP, but I am trying to do something, with IF,Else Statement.

    Basically, I want to put an image on every page except the home page, and we are doing it via our footer.php.

    So what we want to do is have this image display on all pages EXCEPT the home page, so currently what I have is this, but it doesn't seem to be working correctly.

    <?php $file = $_SERVER["SCRIPT_NAME"];

    If ($file="/index.php")
    Else
    <img src=www.domain.com/image.jpg">
    ?>

    Please help if you can, it would be much appreciated.
     
    LindseyInteractive, Apr 21, 2011 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    <?php $file = $_SERVER["SCRIPT_NAME"];
    If ($file=="/index.php")
    {}
    else{
    echo "<img src='http://www.google.co.in/images/nav_logo65.png'>";
    }
    ?>
     
    Bohra, Apr 21, 2011 IP
    SISMediaGroup likes this.
  3. LindseyInteractive

    LindseyInteractive Well-Known Member

    Messages:
    2,826
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Thanks alot Bohra that worked.
     
    LindseyInteractive, Apr 21, 2011 IP