php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31543 get_class_vars does not return private & protected variables
Submitted: 2005-01-13 18:14 UTC Modified: 2005-01-14 02:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: du at bestwaytech dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.3 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: du at bestwaytech dot com
New email:
PHP Version: OS:

 

 [2005-01-13 18:14 UTC] du at bestwaytech dot com
Description:
------------
get_class_vars does not return private and protected variables

Using PHP 5.0.3 with IIS under Windows XP Pro SP2

Reproduce code:
---------------
class test {
  private $a = "private";
  protected $b = "protected";
  public $c = "public";
}
print_r(get_class_vars("test"));

Expected result:
----------------
Array
(
    [a] => private
    [b] => protected
    [c] => public
)


Actual result:
--------------
Array
(
    [c] => public
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-13 18:29 UTC] du at bestwaytech dot com
Just confirmed that it works right using PHP 5.0.2 with same settings
 [2005-01-14 02:25 UTC] jed@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/get_class_vars

"This function will return an associative array of default *public* properties of the class."

If I recall, this didn't work in 5.0.2 either.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Sep 18 06:00:01 2025 UTC