Skip to content Skip to sidebar Skip to footer

Howto Read Currentpage After Index.php?

I'd like to have some help with my code, setting keywords, description and title of the page. My head.php (included in the index.php):

Solution 1:

You can retrieve the anchor fragment (everything after #) by using parse_url(); see: http://php.net/parse_url

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$urlFragment = parse_url( $url, PHP_URL_FRAGMENT );

switch( $urlFragment )
{
    case '!/page_SPLASH':
        $title = "Example.com || Splash";
        $keywords = "splash content";
        $description = "splash description text";
        break;

    /* define more pages here */

    case '!/page_HOME': /* no break; intended */
    default:
        $title = "Example.com || Home";
        $keywords = "some words";
        $description = "description text";
        break;
}

Post a Comment for "Howto Read Currentpage After Index.php?"