Re: [PHP] string as file
- From: stuttle@xxxxxxxxx (Stut)
- Date: Fri, 10 Aug 2007 16:44:49 +0100
Robert Cummings wrote:
On Fri, 2007-08-10 at 16:28 +0100, Stut wrote:Rick Pasotto wrote:On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:Your original post asked...Rick Pasotto wrote:I did. That's why I rejected the use of eval() before I posted theOn Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:RTFM, that's what it's there for.On 8/9/07, Rick Pasotto <rick@xxxxxxxx> wrote:Explain.Does php have a facility similar to python's stringIO?eval()
What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:
$out = <<<EOT
This is an example of $var1 and $var2.
EOT;
and then after assigning values to $var1 and $var2 include that
file. I can later use different values for $var1 and $var2 and get a
different $out with a second include.
One word responses really don't do any good.
Exactly *what* would be the argument to eval()?
message. eval() is totally unsuitable for what I want. Unless, that is,
you or Greg can explain how using eval() will get me what I want.
I think that neither you nor Greg understands what I'm looking for.
Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion.
"Can I someout "include" a string instead of a file?"
That's exactly what eval does. As for what you would pass to it... PHP code maybe? Have you even tried it? The manual page for eval has several examples of how to use it, and the comments have even more.
Use regular expressions or straight string replacements - that's the best way to implement mail-merge type behaviour. Personally I used preg_replace with the 'e' modifier. For an example see, shockingly, the manual page for preg_replace.Incidentally, eval is evil and potentially a giant security hole.Agreed. That's another reason I had already rejected it. Although in
You'd be better off doing replacements with preg_match rather than
executing a string.
this case, since I would have full control of all the variables, it
would probably be ok.
Now "go stick your head in a pig".
Spider-Pig, Spider-Pig, does whatever a Spider-Pig does...
:) I love Fridays!!
It's Friday? Gawdammit!
-Stut
--
http://stut.net/
.
- References:
- string as file
- From: Rick Pasotto
- Re: [PHP] string as file
- From: "Greg Donald"
- Re: [PHP] string as file
- From: Rick Pasotto
- Re: [PHP] string as file
- From: Stut
- Re: [PHP] string as file
- From: Rick Pasotto
- Re: [PHP] string as file
- From: Stut
- Re: [PHP] string as file
- From: Robert Cummings
- string as file
- Prev by Date: Re: [PHP] Friday morning brain farts....
- Next by Date: Re: [PHP] Friday morning brain farts....
- Previous by thread: Re: [PHP] string as file
- Next by thread: Re: [PHP] string as file
- Index(es):