Re: Usage of class constants inside strings and heredocs [message #170500 is a reply to message #170498] |
Wed, 03 November 2010 12:07 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 11/3/2010 5:40 AM, Giuseppe Sacco wrote:
> Álvaro,
> thanks for your prompt answer. I understood what you say about class
> constants and I understood that it is not possible to use class
> constants in heredoc or string text. I just would like to write that
> in my opinion this would really improve readability: I need class
> constants in order to define strings that should never be changeable,
> and I think heredoc are wonderful for creating long and indented text.
> I mean, I just wrote a very simple query, but real queries use as much
> as 20 table fields.
> Using sprintf and such, add runtime complexity for dinamically create
> a static string.
>
> Is there any other *static* way?
>
> Thanks a lot,
> Giuseppe Sacco
If you're trying to use class constants in heredoc or string text,
you're building the string dynamically anyway.
I agree with Micha - sprintf() is good for this; concatenation will also
work but is harder to read, imho.
And no, I don't think the complexity is that great at all, even for 20
fields.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|