Thursday, September 2, 2010

A little bit more about string concatenation, echo and print in PHP

PHP as a language has many interesting features. One of them is string concatenation and special abilities of two the most popular constructs: print and echo. To do not make a lot of text I'll write them all in one example:
What we will see as result?

Let me describe some features related to this code:
  • Only print can be used as function and it alays return 1
  • Only echo allow concat strings by comma
  • Both print and echo can be used without parentheses
On the last feature I was cought up once.

So, let's imagine that we are PHP parsers and look what happens in mentioned code:
So easy features but so many nuances...

More about this topic: on altervista

1 comment:

  1. When I wish for to place gallery or LightBox or yet a slider on my web page I always attempt to use jQuery script in favor of that. What do you think PHP is better or jQuery?

    The Kids Website Design and Marketing 4 Doctors in America.