ID: 28872
Updated by: [EMAIL PROTECTED]
Reported By: nick dot rich at textmarketer dot co dot uk
Status: Open
Bug Type: Class/Object related
-Operating System: Linux
+Operating System: *
PHP Version: 5.0.0RC3
New Comment:
first of all __get() is supposed to return something.
Previous Comments:
------------------------------------------------------------------------
[2004-06-21 19:35:32] nick dot rich at textmarketer dot co dot uk
Description:
------------
Trying to access a propery (via the get method) using a
value from another object as the method name fails.
See code::
if the line /// fails
is
replaced with
$localVar = $config->methodnames[1];
$test->$localVar
It works correctly
Reproduce code:
---------------
class config
{
public $methodnames = array("dog","cat");
}
class testClass
{
function Cat(){
echo "cat";
}
function Dog(){
echo "dog";
}
function __get($method){
eval("\$this->\$method();");
}
}
class main
{
function __construct(){
$config = new config();
$test = new testClass();
$test->$config->methodnames[1]; /// fails
}
}
$test = new main();
Expected result:
----------------
cat
Actual result:
--------------
Fatal error: Call to undefined method testClass::
Object() in /Users/nicholasrich/Sites/bits/
testclass.php(18) : eval()'d code on line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28872&edit=1