Grow your CSS skills. Land your dream job.

Simple If-Statement Not Working

  • # March 24, 2011 at 3:59 pm

    Hey there,

    I have an if statement (not in WordPress; just a simple PHP site) that refuses to work. Thought it was right, guess it’s not?

    Code I have in between my HEAD tags:


    < ?php if($page == 'obituaries') { ?>




    < ?php } ?>

    Code I have after my BODY:


    < ?
    $path = $_SERVER;
    $page = basename($path);
    $page = basename($path, '.php');
    $dir = substr(strrchr(getcwd(), '/'), 1);
    ?>

    I also have the code from Chris Coyier to create a body ID on every page:



    But I can’t figure out how to call a body id even if I wanted to try that way.

    Anybody have any thoughts?

    - Steph

    # March 24, 2011 at 4:06 pm

    It looks like you’re defining your $page variable after you begin the if() statement. If the variable hasn’t been set to “obituaries” yet, it shouldn’t meet that condition.

    I think that’s the problem anyways!

    # March 25, 2011 at 12:42 pm

    That would make sense, I’ll try that!

    Thank you.

    - Steph

    # March 25, 2011 at 5:01 pm

    That worked, thank you!

    - Steph

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".