I have a function that returns an array called curPageURL. On my local apache, I turned to the return value of the page, like this: $pageUrl = explode('?',curPageURL())[0]; he worked very well. But it didn’t work live. It took me a long time to figure out that there was an error accessing the array.
This solved the problem:
$pageUrl = explode('?',curPageURL()); $pageURL = pageURL[0]; function curPageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_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; }
source share