HTML gerçek sayfa linki

4 Cevap php

I'm building a website, and i need to know the actual page address in which the user is in, in order to take users in the same page after login. The problem is that every page is generated from variables passed by url and query string, so I dont't know how to recover every variable and assign to it the correct value. How to recover variables name and assign them the correct values?

Teşekkürler

lore (sorry for my English)

4 Cevap

echo $_SERVER['REQUEST_URI']?

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
?>

Şimdi satırını kullanarak geçerli sayfa URL'sini alabilirsiniz:

<?php
  echo curPageURL();
?>

Bu Sonra ne mi?

Bu (sayfa adı) arıyorsunuz?

echo basename($_SERVER['REQUEST_URI']);

Sen $_SERVER['SCRIPT_URI'] deneyebilirsiniz