Grow your CSS skills. Land your dream job.

PHP Page Titles

  • # September 3, 2012 at 12:44 pm

    I’m sure this is a novice problem but I can’t figure it out..

    I currently used one php file (index2.php) to call the content into the body of the layout using this php include

    < ?php
    if (isset($_GET)) {
    if (file_exists($_GET . '.txt')) {
    include $_GET . '.txt';
    }
    }
    ?>

    my question is that within the content how do I give those pages (about us, testimonials, tax services, etc.) there own titles instead of it defaulting to the index2.php title? I’m trying to be SEO friendly and I know having the same title on every page isn’t going to help my cause. Thanks in advance for your assistance.

    # September 3, 2012 at 12:58 pm

    Set a body id. Then depending on that id write an if-statement echoing the title.

    # September 3, 2012 at 1:00 pm

    Not to sound dumb but how would I do that?

    # September 3, 2012 at 1:25 pm

    I’m still learning, but a simple way I’m using at the moment is using $_GET method from the page url and the page link clicked:




    < ?php
    if ($_GET == 'home'){
    echo ('');
    }
    else if ($_GET == 'contact'){
    echo ('');
    }
    ?>


    Home

    Contact


    # September 3, 2012 at 1:32 pm

    It works, greatly appreciated!

    # September 3, 2012 at 1:46 pm

    I hope you learn from it. You’re welcome.

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

You must be logged in to reply to this topic.

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