note 32380 added to function.str-rot13

From: Date: Mon, 26 May 2003 09:58:46 +0000
Subject: note 32380 added to function.str-rot13
Groups: php.notes 
Request: Send a blank email to php-notes+get-49023@lists.php.net to get a copy of this message
There's a simple way to trick the bug of str_rot13(). As reported in http://bugs.php.net/bug.php?id=20261 , there's a bug with str_rot13(). str_rot13() changes the value of other variables that "linked" to the parameter of str_rot13(). So, if you're using PHP version 4.2.0 until 4.2.3 here's the trick : <? $aaa = "foo"; $bbb = $aaa; $ccc = $bbb; $ddd = str_rot13($ccc.""); //pass a string rather than a variable echo "aaa=$aaa \n"; echo "bbb=$bbb \n"; echo "ccc=$ccc \n"; echo "ddd=$ddd \n"; ?> This way, the result will only stored on variable $ddd, leaving $aaa, $bbb, and $ccc unchanged. If you also want $ccc to be changed (but not $aaa and $bbb), you can do this : <? $ddd = str_rot13(&$ccc); //use the "&" ?> ---- Manual Page -- http://www.php.net/manual/en/function.str-rot13.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32380 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32380&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32380&report=yes

« previous php.notes (#49023) next »