note 109599 modified in language.types.null by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Aug 2012 16:23:31 +0000 |
| Subject: | note 109599 modified in language.types.null by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190023@lists.php.net to get a copy of this message | ||
a quick note about the magic function __get()
: <?php class
Foo{ 	 	protected
$bar; 	 	public function __construct(){
		 		$this->bar =
NULL; 		var_dump( $this->bar ); //prit 'NULL'
but won't call the magic method
__get() 		 		unset( $this->bar
); 		var_dump( $this->bar ); //print 'GET
bar' and
'NULL' 			 	} 	 	public
function __get( $var ){ echo "GET " . $var;
} 		 } new
Foo(); ?>
--was--
a quick note about the magic function __get() :
class Foo{
protected $bar;
public function __construct(){
$this->bar = NULL;
var_dump( $this->bar ); //prit 'NULL' but won't call the magic method __get()
unset( $this->bar );
var_dump( $this->bar ); //print 'GET bar' and 'NULL'
}
public function __get( $var ){ echo "GET " . $var; }
}
new Foo();
http://php.net/manual/en/language.types.null.php