I just tested my web application locally, everything works fine, but after loading the server behavior it behaves differently. I use the formatiraj_string_url function to convert diacritical characters and get a clean url ... locally it works fine, but on the server this function does not convert them the same way.
A few days ago, I tested this on some third server, and it worked fine. Now I download the web to check it again on this third server, but I'm just wondering what could be causing this behavior?
function formatiraj_string_url($string) { $string = strtolower($string); $znak[0] = ' '; $znak[1] = 'ล '; $znak[2] = 'ลก'; $znak[3] = 'ฤ'; $znak[4] = 'ฤ'; $znak[5] = 'ฤ'; $znak[6] = 'ฤ'; $znak[7] = 'ฤ'; $znak[8] = 'ฤ'; $znak[9] = 'ลฝ'; $znak[10] = 'ลพ'; $znak[11] = 'Š'; $znak[12] = 'Đ'; $znak[13] = 'Č'; $znak[14] = 'Ć'; $znak[15] = 'Ž'; $znak[16] = 'š'; $znak[17] = 'đ'; $znak[18] = 'č'; $znak[19] = 'ć'; $znak[20] = 'ž'; $znak[21] = 'Š'; // ล $znak[22] = 'š'; // ลก $zamjena[0] = '-'; $zamjena[1] = 's'; $zamjena[2] = 's'; $zamjena[3] = 'd'; $zamjena[4] = 'd'; $zamjena[5] = 'c'; $zamjena[6] = 'c'; $zamjena[7] = 'c'; $zamjena[8] = 'c'; $zamjena[9] = 'z'; $zamjena[10] = 'z'; $zamjena[11] = 's'; $zamjena[12] = 'd'; $zamjena[13] = 'c'; $zamjena[14] = 'c'; $zamjena[15] = 'z'; $zamjena[16] = 's'; $zamjena[17] = 'd'; $zamjena[18] = 'c'; $zamjena[19] = 'c'; $zamjena[20] = 'z'; $zamjena[21] = 's'; $zamjena[22] = 's'; $string = str_replace($znak, $zamjena, $string); $new_string = preg_replace("/[^a-zA-Z0-9-s]/", "", $string); return $new_string; }
EDIT: before str_replace, this function used preg_replace. On the server, this was an error:
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /home2/sinjcom/public_html/sinj.com.hr/administracija/include/funkcije.php on line 200
But locally I did not have this problem
php apache str-replace
ilija veselica 12 Oct '09 at 19:25 2009-10-12 19:25
source share