From: carl dot b at h2data dot com Operating system: PHP version: 5.0.0 PHP Bug Type: Zend Engine 2 problem Bug description: get_class_vars() return names with NULLs
Description: ------------ The keys in the array returned by get_class_vars() contains NULLs if the field (or variable) is protected or private. A more exact description of the syntax of the keys is listed below. protected: "\x00*\x00<fieldname>" private: "\x00<classname>\x00<fieldname>" public: "<fieldname>" Ok, it's a way to determine the access modifiers of the fields, but as the strings starts with NULL, most PHP functions will think the string is empty as it begins with a null (null-terminated strings). Example is preg_match(). In any case, get_class_vars() isn't supposed to do this kind of work; so any hint of the access shouldn't be included. BTW, is get_class_vars() supposed to only return public fields? As the docs doesn't mentions it, I've assumed not. Reproduce code: --------------- <?php class MyClass { protected $AProtectedField = "orange"; private $APrivateField = "apple"; public $APublicField = "strawberry"; } $fields = get_class_vars('MyClass'); foreach($fields as $name => $value) { echo "$name : $value\n"; } ?> Expected result: ---------------- AProtectedField : orange APrivateField : apple APublicField : strawberry Actual result: -------------- \x00*\x00AProtectedField : orange \x00MyClass\x00APrivateField : apple APublicField : strawberry -- Edit bug report at http://bugs.php.net/?id=29291&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29291&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29291&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29291&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29291&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29291&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29291&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29291&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29291&r=support Expected behavior: http://bugs.php.net/fix.php?id=29291&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29291&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29291&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29291&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29291&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29291&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29291&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29291&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29291&r=float