Re: [PHP4BETA] eval'ing a method

From: Date: Fri, 05 May 2000 18:16:02 +0000
Subject: Re: [PHP4BETA] eval'ing a method
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-14545@lists.php.net to get a copy of this message
Just a comment, I don't know in theory if this will work, I really doubt it will as-is.. I see some problems with scope and special characters that I won't get into.. Still. People posting actual code here and asking if it works seems a bit silly to me. Try it! Then you'll KNOW if your code works! Someone once told me that you know you're a good programmer when code you write on a napkin works flawlessly. I don't know too many good programmers if that's the requirement :-) Perhaps you should have posted the idea or what you wanted to get accomplished and taken ideas from what people have say. So... I take it you want to store actual PHP code in a database and yank it out / execute it accordingly? Great question! Try it! Have a good one.. -Mitch ----- Original Message ----- From: Mark Constable <markc@renta.net> To: <php4beta@lists.php.net> Sent: Friday, May 05, 2000 1:37 PM Subject: [PHP4BETA] eval'ing a method > I this possible ? ($m is really coming from an SQL lookup) > > <?php > class blah { > var $somevar = 1; > > function somemethod() { > $m = "function somefunc() { $this->somevar = 2; }"; > eval($m); > $this->somefunc(); > echo "this->somevar=$this->somevar<br>\n"; > } > } > $x = new blah; > $x->somemethod(); > echo "x->somevar=$x->somevar<br>\n"; > ?> > > Parse error: parse error in Unknown on line 0 > Fatal error: Call to undefined function: somefunc() \ > in /pub/blahtest.php on line 8 > > --markc > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net > >

« previous php.version4 (#14545) next »