On Saturday 11 July 2009 16:05:55 tedd wrote:
> At 3:42 PM +0100 7/11/09, Ashley Sheridan wrote:
> >On Saturday 11 July 2009 15:23:55 tedd wrote:
> >  > At 8:34 PM -0400 7/10/09, Daniel Brown wrote:
> >
> >-snip-
> >
> >  > >$html =<<<HTML
> >>  >
> >>  ><b>File Name:</b> {$filedata['name']}<br />
> >>  ><b>File Size:</b> {$filedata['size']}<br />
> >>  >
> >  > ><b>\$somevar</b>: {$somevar}<br />
> >  > >
> >  > >HTML;
> >>  >
> >>  >echo $html;
> >>  >?>
> >  >
> >  > Daniel:
> >  >
> >  > Why the braces?
> >  >
> >  > tedd
> >
> >The braces ensure that PHP doesn't stop parsing the variable name once it
> >reaches the [. By default, it will only match a variable name up to the [
> >sign, so you couldn't access arrays without the braces.
> >
> >Ash
>
> Ash:
>
> Ahhh, the arrays -- I should have looked further up.
>
> I just noticed:
>
>     <b>\$somevar</b>: {$somevar}<br />
>
> and wondered why, because:
>
>     <b>\$somevar</b>: $somevar<br />
>
> will work.
>
> Side note: Paul Novitski showed me using an underscore for heredocs:
>
> $html =<<<_
> whatever
> _;
>
> That I thought was kind of neat. To me it makes heredocs stand out
> and are more uniform.
>
> In any event, thanks,
>
> tedd
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com

I would try to avoid heredoc delimiters of a single character, just in case ;)

What I tend to do is to use <<<EOC where the last letter changes depending on 
what content I'm outputting. It makes no difference, but reading back later 
it helos me understand what I was doing. So I'd use EOX for XML, EOF for 
forms, OEC for general content, etc.

I only do it this way because I remember reading somewhere (If forget exactly 
where now) that it is better to use 3 or more characters in uppercase so they 
stand out well from the rest of the code.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to