This is a discussion on How to Escape Ternary Within Here Document? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, How do I escape a ternary statement within a 'here document' construct? Example: echo <<<EOS Some ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Michael Ruebner schreef:
> Hi, > > How do I escape a ternary statement within a 'here document' construct? > > Example: > > echo <<<EOS > Some stuff here. > Some more stuff. > (check($this))?'Even more stuff!':'Enough!' > EOS; > > TIA > > Mike Hi Mike, The answer is simple: You dont. Only simple variable substituation is done inside a heredoc. So the easiest solution for you probably is: do the ternary statement before the heredoc, and use its results (in a plain var) inside the heredoc. Or start using some templatesystem if that suits your needs. Good luck. Regards, Erwin Moller |
|
|||
|
Michael Ruebner schreef:
> Erwin Moller: > >> Only simple variable substituation is done inside a heredoc. > > Well, not the answer I was hoping for, but probably to be expected ;-) > Back to echo-vaganza... > > Thanks, > > Mike Hi Mike, I also suggested: "So the easiest solution for you probably is: do the ternary statement before the heredoc, and use its results (in a plain var) inside the heredoc." Isn't that an easy way out? I mean, compared to echo-vaganza a heredoc is much easier to read. A few $varnames in it helps to keep your HTML code easily readable, compared to echos. Anyway, good luck. :-) Regards, Erwin Moller |
|
|||
|
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in message news:481ecba1$0$14358$e4fe514c@news.xs4all.nl... <snip> > Isn't that an easy way out? > I mean, compared to echo-vaganza a heredoc is much easier to read. > A few $varnames in it helps to keep your HTML code easily readable, > compared to echos. Tried finding echo-vaganza in Google, no returns. Is this a standard term in PHP5? Paul |
|
|||
|
PaulB schreef:
> "Erwin Moller" > <Since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in > message news:481ecba1$0$14358$e4fe514c@news.xs4all.nl... > <snip> >> Isn't that an easy way out? >> I mean, compared to echo-vaganza a heredoc is much easier to read. >> A few $varnames in it helps to keep your HTML code easily readable, >> compared to echos. > > Tried finding echo-vaganza in Google, no returns. Is this a standard term > in PHP5? > > Paul Hi Paul, No, it is a joke. I never heard of it either untill Michael used it. Maybe he has invinted the word himself. I don't know. But Michael's new word clearly conveys what he ment. echo + extravaganza. I think it is a great word to describe a echo-mess, compared to cleaner HTML in a heredoc. I like it. :-) Regards, Erwin Moller |
![]() |
| Thread Tools | |
| Display Modes | |
|
|