php değişkenler ile tam url ayıklanması

3 Cevap

Using Php I would like to extract the current Url of a page including all variables attached to it. $_SERVER['PHP_SELF'] only return the url without the variable . any idea what function I need.

Örnek: www.site.com/?v1=xyz&v2=123

using $_SERVER['PHP_SELF'] I get only : www.site.com as opposed to the whole url. using $_GET[] individually is not an opton since I am not sure what variable are attached to the URL.

teşekkür ederim

3 Cevap

Siz çıkış $_SERVER süper küresel değişkenin içeriğini olabilir: çok ilginç şeyler vardır orada ;-)


For example, calling a page with an URL like this :

http://localhost/temp/temp.php?a=10&b=glop

Ve kullanarak:

var_dump($_SERVER);

Ben en azından olsun:

array
  ...
  'HTTP_HOST' => string 'localhost' (length=9)
  ...
  'REQUEST_METHOD' => string 'GET' (length=3)
  'QUERY_STRING' => string 'a=10&b=glop' (length=11)
  'REQUEST_URI' => string '/temp/temp.php?a=10&b=glop' (length=26)
  'SCRIPT_NAME' => string '/temp/temp.php' (length=14)
  'PHP_SELF' => string '/temp/temp.php' (length=14)
  'REQUEST_TIME' => int 1270060299


In there, I suppose at least those could interest you :

  • $_SERVER['QUERY_STRING']: Bütün sorgu dizesini içerir; Tüm parametreler ve değerleri yani listesi
  • $_SERVER['REQUEST_URI']: - parametreleri içeren istenen URI içerir
$request = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'];

Tüm yolu ve Sorgu dizeleri.

$_SERVER['QUERY_STRING'] değişkenleri bölümünü almak için kullanın.

Şerefe