note 74115 added to ref.strings
| From: | benjamin at webbutvecklarna dot se | Date: | Mon, 26 Mar 2007 00:23:05 +0000 |
| Subject: | note 74115 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124799@lists.php.net to get a copy of this message | ||
An update to admin at fivestarbuy dot com's StrParse. Since php5.2.x the occurance of an object
in the vardata will cause a "Catchable fatal error". Previously it has failed silently, so
I added nullification of present objects.
I also updated comments to be more specific, I hope that's ok with you, admin at fivestarbuy
dot com:
<?php
function StrParse($str,$vardata) {
# Variables present in $str is replaced by values of variables in $vardata
# typical use:
# $vardata = get_defined_vars();
# $str = some template code with variables present.
# uncomment the echo line to debug.
$getvarkeys=array_keys($vardata);
$ret=$str;
for ($x=0; $x < count($getvarkeys); $x++) {
$myvar=$getvarkeys[$x];
if(is_object($vardata[$myvar])) $vardata[$myvar] = null;
#echo "Variable: " . $myvar . " [" . $vardata[$myvar] .
"]<br>";
$ret=str_replace('$' . $myvar, $vardata[$myvar], $ret);
}
return $ret;
}
?>
----
Server IP: 129.16.214.50
Probable Submitter: 81.225.26.196
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit -- https://master.php.net/note/edit/74115
Del: integrated -- https://master.php.net/note/delete/74115/integrated
Del: useless -- https://master.php.net/note/delete/74115/useless
Del: bad code -- https://master.php.net/note/delete/74115/bad+code
Del: spam -- https://master.php.net/note/delete/74115/spam
Del: non-english -- https://master.php.net/note/delete/74115/non-english
Del: in docs -- https://master.php.net/note/delete/74115/in+docs
Del: other reasons-- https://master.php.net/note/delete/74115
Reject -- https://master.php.net/note/reject/74115
Search -- https://master.php.net/manage/user-notes.php