Lu Jia
Active member
Hi all,
I want to ask you if is there a way with xenforo's api to get the current page's url
At the moment i'm using this function:
But it will return an error. It can be fixed if u comment the https line:
Is there an other way to do it?
Thanks in advance
I want to ask you if is there a way with xenforo's api to get the current page's url
At the moment i'm using this function:
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;
}
echo curPageURL();
But it will return an error. It can be fixed if u comment the https line:
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;
}
echo curPageURL();
Is there an other way to do it?
Thanks in advance