I have the following line of code to retrieve and decode a URL before checking it against my database:
$urls = url_split(url_current());
$url_page = (string)rawurldecode($url[0]);
The URL gets split and put into an array using the following functions:
function url_current ()
{
// Check for HTTPS
$http = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") $http .= 's';
$http .= '://';
// Return URL
return $http . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
}
function url_split ($url)
{
// Retrieve URLs - Remove URL and split into array
$url = explode('/', str_replace('http://www.siteurl.com', '', $url));
// Build new array, remove blanks
$urls = array();
for ($i = 0; $i < sizeof($url); $i++)
{
if ($url[$i] != '') $urls[] = $url[$i];
}
// Return array
return $urls;
}
This is working on my local server (using Zend) but it isn’t working on my live server. This shouldn’t be an issue with the $_SEVER variables as these are all returning the correct data. I’ve no idea why this would perform differently on my local server compared to my live server. Is there any set up in the php ini that might be causing this?
On my local server yrj%C3%B6laitinen produces yrjölaitinen but on my live server it produces yrjölaitinen.
Ok problem solved. I’m afraid this was linked my PDO database connection. I hadn’t updated the code to force UTF-8:
Apologies for wasting anyones time looking at this. It was my own stupid fault!