Backticks, EOL, and Break

While studying up for the Zend PHP Certification exam I came across a few more elements that I’ve never used before.

Firstly, there is a backtick operator. This makes it possible to execute a shell command and retrieve
its output. For example,the following will cause the output of the UNIX ls command to be stored inside $a:

  2. $a = ‘ls -l‘;

Secondly, PHP has an end of line constant. I’ve never seen PHP_EOL before but it seems to work similar to “\n”.
I don’t think I will ever use this due to the length when compared with “\n”.

Finally, a bit about the break function. I had no idea that both the break and continue statements take a
paramenter which can instruct them to break out of multiple loops. I felt a bit silly that I didn’t already know this.
Here is a simple example:

  2. for ($i = 0; $i < 10; $i++) {
  3.         for ($j = 0; $j < 3; $j++) {
  4.                 if (($j + $i) % 5 == 0) {
  5.                         break 2; // Exit from this loop and the next one.
  6.                 }
  7.         }
  8. }

There seems to be a lot that I’m going to have to study up on before I can become a Zend Certified Engineer.