|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-16 23:45 UTC] floyd dot mcmichael at alaska dot gov
Description:
------------
preg_replace blanks a string that it didn't use to in previous versions of PHP 5.x. other preg_replace strings not affected
Reproduce code:
---------------
function doSmiles($string, $skinname)
{
$patterns = array(
"/\[alien\]/i",
... snipped due to length ...
"/\[crazy\]/i"
);
$replacements = array(
"<img src=\"./skin/$skinname/emotes/alien.png\" alt=\"alien\" title=\"alien\">",
... snip due to length ...
"<img src=\"./skin/$skinname/emotes/crazy.png\" src=\"./skin/$skinname/emotes/crazy.png\" alt=\"crazy\" title=\"crazy\">"
);
$string = preg_replace($patterns, $replacements, $string);
return $string;
}
Expected result:
----------------
print substrings like [alien] to html-valid strings like <img src="./skin/default/alien.png">. prior to upgrading to 5.2.5 this particular function DID work. it no longer works.
Actual result:
--------------
returns a blank string ""
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 02:00:01 2025 UTC |
reviewed preg_replace string again and realized two non-alphanumeric characters were not escaped. (specifically two "(" ) re-ran and now the preg_replace string works. this must have been a change in 5.2.5 but now that the ('s are escaped the function works properly.