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:
-
-
$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:
-
-
for ($i = 0; $i < 10; $i++) {
-
for ($j = 0; $j < 3; $j++) {
-
if (($j + $i) % 5 == 0) {
-
break 2; // Exit from this loop and the next one.
-
}
-
}
-
}
-
There seems to be a lot that I’m going to have to study up on before I can become a Zend Certified Engineer.