NYCPHP Meetup

NYPHP.org

[nycphp-talk] heredoc help please?

Steve Manes smanes at magpie.com
Thu Jan 31 13:19:03 EST 2008


Urb LeJeune wrote:
>         BTW there is no <br /> after "lines." The fact that there is no 
> nl following the last line of
> the document has always been a mystery to me. PHP supposedly allows 
> white spaces in most
> places. I could also never understand why spaces are not allowed after 
> the opening or closing
> label.

In "classic" heredoc syntax, \nTOKEN is treated by the parser as the 
end-of-doc token, not just TOKEN.  In Perl, it's \nTOKEN\n.  This 
actually comes in handy for CLI scripts were you want to use it dump a 
bunch of text with a closing prompt:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent est 
libero, rutrum in, viverra vehicula, consequat non, ante. Praesent nibh 
arcu, congue ac, bibendum eget, consequat vel, nunc. Nullam fermentum 
cursus magna. Nulla egestas justo vel ipsum. Sed vitae lectus in ipsum 
tristique ullamcorper.

Would you like to play a game of chess (y/n)? _




More information about the talk mailing list