note 114281 added to function.property-exists

From: Date: Sun, 02 Feb 2014 13:44:04 +0000
Subject: note 114281 added to function.property-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-198387@lists.php.net to get a copy of this message
When you are testing for a property that has been added dynamically, you will need to provide a reference to the instance rather than the class name for the first parameter. For example, for this code snippet: class myClass { public $var; } $obj = new myClass; $obj->new_var = "new"; var_dump(property_exists('myClass', 'new_var') ); var_dump(property_exists($obj, 'new_var') ); Returns: boolean false boolean true ---- Server IP: 113.20.13.217 Probable Submitter: 202.89.190.17 ---- Manual Page -- http://php.net/manual/en/function.property-exists.php Edit -- https://master.php.net/note/edit/114281 Del: integrated -- https://master.php.net/note/delete/114281/integrated Del: useless -- https://master.php.net/note/delete/114281/useless Del: bad code -- https://master.php.net/note/delete/114281/bad+code Del: spam -- https://master.php.net/note/delete/114281/spam Del: non-english -- https://master.php.net/note/delete/114281/non-english Del: in docs -- https://master.php.net/note/delete/114281/in+docs Del: other reasons-- https://master.php.net/note/delete/114281 Reject -- https://master.php.net/note/reject/114281 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198387) next »