note 28788 added to function.get-class-vars
| From: | rec at NOSPAM dot instantmassacre dot com | Date: | Thu, 23 Jan 2003 22:23:29 +0000 |
| Subject: | note 28788 added to function.get-class-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42663@lists.php.net to get a copy of this message | ||
If you want to retrieve the class vars from within the class itself, use $this.
<?php
class Foo {
var $a;
var $b;
var $c;
var $d;
var $e;
function GetClassVars()
{
return array_keys(get_class_vars(get_class($this))); // $this
}
}
$Foo = new Foo;
$class_vars = $Foo->GetClassVars();
foreach ($class_vars as $cvar)
{
echo $cvar . "<br />\n";
}
?>
Produces, after PHP 4.2.0, the following:
a
b
c
d
e
--
http://www.php.net/manual/en/function.get-class-vars.php
http://master.php.net/manage/user-notes.php?action=edit+28788
http://master.php.net/manage/user-notes.php?action=delete+28788
http://master.php.net/manage/user-notes.php?action=reject+28788