note 94576 added to function.str-replace
| From: | jonathon at compwright dot com | Date: | Thu, 12 Nov 2009 17:23:41 +0000 |
| Subject: | note 94576 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162817@lists.php.net to get a copy of this message | ||
If you get a blank page when passing an object to str_replace() (relying on __toString() to convert
the object to a string) then you may need to force string context using (string), like so:
private function _load_vars($vars, &$source = false) {
if(!$source) $source =& $this->code;
foreach((array)$vars as $key => $var) {
$source = str_replace("{".$key."}", (string) $var, $source);
}
}
}
I was running Ubuntu Server with PHP 5.2.6 and getting apache segfaults and mysterious blank pages
when $var happened to be certain objects.
----
Server IP: 69.147.83.197
Probable Submitter: 173.133.167.238
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/94576
Del: integrated -- https://master.php.net/note/delete/94576/integrated
Del: useless -- https://master.php.net/note/delete/94576/useless
Del: bad code -- https://master.php.net/note/delete/94576/bad+code
Del: spam -- https://master.php.net/note/delete/94576/spam
Del: non-english -- https://master.php.net/note/delete/94576/non-english
Del: in docs -- https://master.php.net/note/delete/94576/in+docs
Del: other reasons-- https://master.php.net/note/delete/94576
Reject -- https://master.php.net/note/reject/94576
Search -- https://master.php.net/manage/user-notes.php