Bug #17537 Updated: get_class_vars works unexpected
| From: | eru@php.net | Date: | Tue, 02 Jul 2002 21:21:09 +0000 |
| Subject: | Bug #17537 Updated: get_class_vars works unexpected | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-12876@lists.php.net to get a copy of this message | ||
ID: 17537
Updated by: eru@php.net
Reported By: mrbrush@harem.dev.hu
-Status: Open
+Status: Verified
Bug Type: Documentation problem
Operating System: Linux 2.4.
PHP Version: 4.2.1
Previous Comments:
------------------------------------------------------------------------
[2002-05-31 02:45:57] derick@php.net
Reclassify as doc problem
------------------------------------------------------------------------
[2002-05-30 21:08:01] mrbrush@harem.dev.hu
The documentation says that the get_class_vars() method should return
an array only with the properties wich had DEFAULT values already at
class definition. That worked fine with PHP 4.1.2 but it's behavior
changed with PHP 4.2.[0 or 1] because it displays also those properties
which has no default values at definition. I don't really think that
this is a bug, but it seems that there was a change in the function
behavior and neither the changelog nor the documentation mentions a
word about this change.
Example - the following script from the docs:
<?php
class myclass {
var $var1; // this has no default value...
var $var2 = "xyz";
var $var3 = 100;
// constructor
function myclass() {
return(true);
}
}
$my_class = new myclass();
$class_vars = get_class_vars(get_class($my_class));
echo "<pre>";
foreach ($class_vars as $name => $value) {
echo "$name : $value\n";
}
echo "</pre>";
?>
should outuput something like this:
var2 : xyz
var3 : 100
but the result in PHP 4.2.1 is:
var1 :
var2 : xyz
var3 : 100
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17537&edit=1