note 58138 added to function.get-class-vars

From: Date: Tue, 25 Oct 2005 13:25:52 +0000
Subject: note 58138 added to function.get-class-vars
Groups: php.notes 
Request: Send a blank email to php-notes+get-97572@lists.php.net to get a copy of this message
Contrary to multiple comments throughout the manual, get_class_vars() performed within a class can access any public, protected, and private members. <?php class Foo { public $x; protected $y; private $z; public function __sleep() { return( get_class_vars( __CLASS__ ) ); } } ?> works fine (returns x, y, & z). However, given the same class as above, <?php print_r( get_class_vars( "Foo" ) ); ?> will NOT return x, y, & z. Instead it will only return the public members (in our case, z). ---- Manual Page -- http://www.php.net/manual/en/function.get-class-vars.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58138 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58138&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58138&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97572) next »