|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-10-10 21:48 UTC] asynchronio at gmail dot com
Description:
------------
ReflectionProperty name getter returns false, but getting name directly works
fine.
Test script:
---------------
<?php
class Test {
public $foo = 1;
public $bar = 2;
public function test()
{
$class = new ReflectionClass(get_class($this));
$names = array();
foreach($class->getProperties() as $property)
{
$names[] = $property->getName();
// This code works:
// $names[] = $property->name;
}
return $names;
}
}
$test = new Test();
var_dump($test->test());
Expected result:
----------------
array(2) { [0]=> 1 [1]=> 2 }
Actual result:
--------------
array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 13:00:02 2025 UTC |
Sorry, invalid data posted in Expected / Actual results I've meant: Expected result: ---------------- array(2) { [0]=> string(3) "foo" [1]=> string(3) "bar" } Actual result: -------------- array(2) { [0]=> bool(false) [1]=> bool(false) }Hm, interesting thing - i've found this example working fine via "php -e <test.php>", but it's not working via builtin web-server ("php -S localhost:8000" and then requesting script via browser)