Re: fgets and eval

From: Date: Wed, 19 Dec 2001 06:17:54 +0000
Subject: Re: fgets and eval
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-78184@lists.php.net to get a copy of this message
> Okay here is the situation. I am reading a file using fgets up until I hit a certain delimiter within the text. No problem there. This text file may or may not > contain php in the format <? blah ?>. So I now have two variables $header and $footer which may or may not contain some php within them. I need to echo > the variables at the top and bottom of other files but need any php that may be in there to execute. > > I tried echo(eval($header)) > > and I also tried > > $header = addslashes($header); > eval("\$header = \"$header\";"); > $header= stripslashes($header); > echo($header); > > The first produces and error, the second produces no error however only variables evaluate while actual commands, such as echo just get written into the > code. > > Any idea what I may be doing wrong here? Try this, it's from a template parsing function I wrote: $header = str_replace("\\'","'",addslashes($header)); eval("\$header = \"$header\";"); Greg

« previous php.general (#78184) next »