echo "Hello, world!";;; ;; ; 

I always thought that the script would not work, explain why it works?

  • What exactly is a mistake? - Herrgott
  • 3
    semicolon separates instructions. many comma points mean only that there is an empty instruction ahead - Alexey Shimansky
  • @ Alexey Shimansky strange I thought that at least E_NOTICE would work here - wwwplaton
  • one
    syntactic sugar ... - Urmuz Tagizade

1 answer 1

A semicolon separates instructions. Theoretically echo "Hello, world"; looks like that:

 { Вывести строчку "Hello, world!" } 

That is, there is a block, isolated, instruction that must be executed.

Many commas mean only that in theory it would look like this

 {} {} {} 

A bunch of empty blocks in which there is nothing and nothing to be executed.

And by themselves, {} is a completely legal construction ... To which, as we know, all conditions if or functions of function test() {} , etc. are separated.

For example, you can safely write:

 <?php { echo 'Вот оно чё, Михалыч<br />'; $magic = 'Это магия какая-то!'; echo $magic; } ?> 

And it will work