Re: get_class_vars bug??

From: Date: Thu, 07 Sep 2000 08:35:48 +0000
Subject: Re: get_class_vars bug??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15675@lists.php.net to get a copy of this message
The manual says: "Returns an array of DEFAULT properties of the class": It only returns the properties, if they has been defined. Try: class start { var $first_name = "Hello"; var $last_name; var $company; } $vars = get_class_vars(start); foreach($vars as $key => $value) { print $key." = ".$value."<BR>"; } $instance = new start(); $vars = get_object_vars($instance); foreach($vars as $key => $value) { print $key." = ".$value."<BR>"; } Adam Weisbart wrote: > Greetings, > > I'm running 4.0.1pl2 and can't get get_class_vars to work. Here's what I > have tried: > > <? > class start_vars_list { > var $first_name; > var $last_name; > var $company; > } > > $vars = get_class_vars(start_vars_list); > echo $vars[1]; > > ?> > > $vars is an array, but contains no data. I was thinking that echo $vars[1]; > should give me "last_name" but it does not give me anything!? > > Any ideas? I'm going nuts!!! > > Thanks, > > -Adam > > -- > W e b G l o w Your Site, Our Insight > Adam Weisbart | adam@webglow.com | http://webglow.com > Phone: (831) 459-7671 Toll Free: 877-WEB-GLOW > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#15675) next »