Re: problem with eval()

From: Date: Fri, 14 Jul 2000 05:14:18 +0000
Subject: Re: problem with eval()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6599@lists.php.net to get a copy of this message
It just takes a bit of fiddling. Conceptually it is correct. And yes, I spent the 2 minutes to do the fiddling for you. Here you go: <? $value=1; $today=1; $complete_code = '($value == $today) ? "Hello World" : ""'; eval("\$new_string = $complete_code;"); echo $new_string; ?> -Rasmus On Fri, 14 Jul 2000, Alan Gillespie wrote: > 'fraid these suggestions don't work either. > > maybe I'm expecting PHP to do too much other than the > simple replacement of values in Strings. > I accept that if I declare variables > $value = 1 and > $today = 1 > > in my 'application' then parse the Src_File it > substitutes the values of $value & $today for their > numeric value, but I thought I should still be able to > evaluate/process the statement, and if there is any > result/output, pass this back to the string you've > assigned ($new_string) > > very puzzled & confused, > > alan > > > > > > > You probably want something along the lines of: > > > > > > $complete_code = '($value == $today) ? "Hello > World" : ""'; > > > > > > and then > > > > > > eval("\$new_string = \"$complete_code\";); > > > > Actually, get rid of the \"'s there. > > > > -Rasmus > > >

« previous php.general (#6599) next »