How to get current, past and server URL with php

Inleiding

When you want to get the current URL of a site there is a PHP code

Stappen

Im forgetting this all the time. How do you get the current URL etc:

Get variable only:

$_GET['bg'];

Get the left complete server part:

$_SERVER["DOCUMENT_ROOT"]

Get the right part:

$_SERVER['REQUEST_URI']

Get only host

$_SERVER['HTTP_HOST']

Get no seo:

$_SERVER["QUERY_STRING"],

Previous url

getenv('HTTP_REFERER');

Tips

Substr in another one I always forget

$rest = substr ("abcdef", 1); // geeft "bcdef" $rest = substr ("abcdef", 1, 3); // geeft "bcd" $rest = substr ("abcdef", 0, 4); // geeft "abcd" $rest = substr ("abcdef", 0, 8); // geeft "abcdef"

$rest = substr ("abcdef", -1); // geeft "f" $rest = substr ("abcdef", -2); // geeft "ef" $rest = substr ("abcdef", -3, 1); // geeft "d"

Handige links


Reacties (0)

Reageer
Geen resultaten gevonden