How to Escape Ternary Within Here Document?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 1 Week Ago
Michael Ruebner
 
Posts: n/a
Default How to Escape Ternary Within Here Document?

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
Reply With Quote
  #2 (permalink)  
Old 1 Week Ago
Erwin Moller
 
Posts: n/a
Default Re: How to Escape Ternary Within Here Document?

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
Reply With Quote
  #3 (permalink)  
Old 1 Week Ago
Michael Ruebner
 
Posts: n/a
Default Re: How to Escape Ternary Within Here Document?

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
Reply With Quote
  #4 (permalink)  
Old 1 Week Ago
Erwin Moller
 
Posts: n/a
Default Re: How to Escape Ternary Within Here Document?

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
Reply With Quote
  #5 (permalink)  
Old 6 Days Ago
PaulB
 
Posts: n/a
Default Re: How to Escape Ternary Within Here Document?

"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


Reply With Quote
  #6 (permalink)  
Old 5 Days Ago
Erwin Moller
 
Posts: n/a
Default Re: How to Escape Ternary Within Here Document?

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:39 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0