ID: 9137
Updated by: waldschrott
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Class/Object related
Assigned To: waldschrott
Comments:

and this is correct, eval uses its own scope, the only
possibilty I see at the moment to solve your specific
problem is to eval() the entire class maybe in combination
with inheritance

Previous Comments:
---------------------------------------------------------------------------

[2001-02-06 17:32:47] [EMAIL PROTECTED]
I am trying to generate class methods on the fly.

I created a string which was php code for a function. I wished this funciton to be a 
class method. I call eval on the string, and it produces no errors. When I wish to 
call that method of the object, the script fails indicating a call to an undefined 
funciton. However, I can call that function in the page space, rather than as a class 
method. But, the function is useless unless it is a method.

The following is part of the code that is executed in the constructor:

$str = "";
foreach($this->getMappedAttributes() as $attribute)
{
  $str .= "$"."this->_".$attribute['attribute']." = "";";
  $str .= "function get".$attribute['attribute']."() {";
  $str .= "return $"."this->_".$attribute['attribute'].";}";
}
eval($str);


---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9137&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to