note 90287 deleted from language.oop5.magic by danbrown

From: Date: Tue, 14 Apr 2009 20:18:07 +0000
Subject: note 90287 deleted from language.oop5.magic by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153220@lists.php.net to get a copy of this message
Note Submitter: isaac dot raway at sierra-bravo dot com ---- In reply to muratyaman at gmail dot com This is NOT unexpected. I would expect recursion because the -> is not interpreted inside of strings unless you wrap the whole expression in braces. Therefore PHP is trying to get the string value of $this followed by "->" then the string value of $attrib. <?php //This causes RECURSION because of parsing between double quotes. This is a very UNEXPECTED behaviour! function nz_($attrib){ $s = ''; if($this->$attrib != '') $s = "$attrib = \"$this->$attrib\""; return $s; } ?> You probably meant: <?php if($this->$attrib != '') $s = "$attrib = \"{$this->$attrib}\""; ?>

« previous php.notes (#153220) next »