FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Usage of class constants inside strings and heredocs
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Usage of class constants inside strings and heredocs [message #170500 is a reply to message #170498] Wed, 03 November 2010 12:07 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  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
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Free Web Space for our Experiments
Next Topic: There is some framework/tool to generate PHP code
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 14 01:27:56 GMT 2024

Total time taken to generate the page: 0.03266 seconds