Re: string as file
| From: | Rick Pasotto | Date: | Fri, 10 Aug 2007 15:13:22 +0000 |
| Subject: | Re: string as file | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260583@lists.php.net to get a copy of this message | ||
On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:
> Rick Pasotto wrote:
>> On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:
>>> On 8/9/07, Rick Pasotto <rick@niof.net> wrote:
>>>> Does php have a facility similar to python's stringIO?
>>>>
>>>> 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.
>>> eval()
>> Explain.
>> One word responses really don't do any good.
>> Exactly *what* would be the argument to eval()?
>
> RTFM, that's what it's there for.
I did. That's why I rejected the use of eval() before I posted the
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.
> Incidentally, eval is evil and potentially a giant security hole.
> You'd be better off doing replacements with preg_match rather than
> executing a string.
Agreed. That's another reason I had already rejected it. Although in
this case, since I would have full control of all the variables, it
would probably be ok.
--
"Whatever crushes individuality is despotism, by whatever name it may be
called." -- John Stuart Mill, 1859
Rick Pasotto rick@niof.net http://www.niof.net