How to use objects, variables in an eval() func ?

From: Date: Tue, 10 Jun 2003 17:11:47 +0000
Subject: How to use objects, variables in an eval() func ?
Groups: php.general 
Request: Send a blank email to php-general+get-150943@lists.php.net to get a copy of this message
Hi, I have an eval which evaluate a block of code before echo the result on the screen.. Here is the func : function t_eval($texte) { ob_start(); eval("?>".$texte); $retval = ob_get_contents(); ob_end_clean(); return $retval; } But I use some objects for databases, ... and when i trying to execute this code i have this text. Fatal error: Call to a member function on a non-object in k:\program files\easyphp\www\dhea\include\php\functions_conversion.inc.php(23) : eval()'d code on line 9 What to do ? I've tried to insert a global in t_eval function and do the following code eval("<?php GLOBAL $myclasses; ?>".$texte); Thanx Laurent

« previous php.general (#150943) next »