|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-04 01:36 UTC] juho dot karvilainen at bmf dot wz dot cz
Description:
------------
looks like the strtr() function (when used with array as 2nd argument) nibbles a character from the end when it has nothing to replace. (on UTF-8 page)
Reproduce code:
---------------
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php
function safe_js($str){
return strtr($str,array('"'=>'\"',"'">'\'','/'=>'\/'));
}
?>
line1...<?php echo safe_js(480)?>
line2...
Expected result:
----------------
line1...480
line2
Actual result:
--------------
line1...48line2
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 11 19:00:02 2025 UTC |
Your array is also malformed. array('"'=>'\"',"'">'\'','/'=>'\/') array(3) { ["""]=> string(2) "\"" [0]=> bool(false) ["/"]=> string(2) "\/" }