note 90287 added to language.oop5.magic

From: Date: Tue, 14 Apr 2009 20:17:16 +0000
Subject: note 90287 added to language.oop5.magic
Groups: php.notes 
Request: Send a blank email to php-notes+get-153219@lists.php.net to get a copy of this message
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}\""; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 67.152.160.2 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.magic.php Edit -- https://master.php.net/note/edit/90287 Del: integrated -- https://master.php.net/note/delete/90287/integrated Del: useless -- https://master.php.net/note/delete/90287/useless Del: bad code -- https://master.php.net/note/delete/90287/bad+code Del: spam -- https://master.php.net/note/delete/90287/spam Del: non-english -- https://master.php.net/note/delete/90287/non-english Del: in docs -- https://master.php.net/note/delete/90287/in+docs Del: other reasons-- https://master.php.net/note/delete/90287 Reject -- https://master.php.net/note/reject/90287 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153219) next »