jax.be

Often wrong, never in doubt

PHP5 Certified!

May28th

As I'm on my way to become a real freelancer I need all the certifications I can get. Last week I got my first one, I'm now a Zend Certified Engineer. The exam was a bit strange since it asks very specific questions you're unlikely to encounter in the real world and that are easily tested or looked up. I think that a lot of the questions were not questions that tested your PHP5 programming skills but rather the inane details of the language.

An example:
What is the result of:

<?php
$a = 3;
switch($a) {
case 1: echo 'one'; break;
default: echo 'four'; break;
case 3: echo 'three'; break;
}
?>
I answered "four" on this one since I reasoned that it was evaluated in order. Not only because that seemed natural but also because omitting a 'break' statement just causes the flow to continue. Well, I was wrong. The correct answer is "three". This behavior isn't even documented: http://www.php.net/switch

Oh, and you better learn your scoping rules as well. Another example:
<?php
class Foo {
protected $value = 'Hello';
function bar() {
echo $this->value;
}
}
class Baz {
protected $value = 'World';
function qux() {
Foo::bar();
}
}
$b = new Baz();
$b->qux();
?>
Will this output anything? And if it does, what? The first thing I thought was: "Who would do something like this?". Then I thought it must give an error since bar is called statically and $this will/should not exist within bar(). But then I reasoned PHP5 usually does things somewhat different. I answered 'Hello' but that is not correct, a stupid mistake since if a $this exists it would be the Baz instance. The correct result here is "World".

And last but not least you should know what triggers notices, warnings and errors. Another example:
<?php
class Foo {
private $value = 'Hello';
}
class Bar extends Foo {
function baz() {
echo $this->value;
}
}
$b = new Bar();
$b->baz();
?>
What does this do? Okay, you know that $value should not be visible to Bar but I haven't actually tried it before. This plainly gives an "undefined property" notice.

So, one down some to go. I'm thinking about completing some more certifications. The ones I'm pondering are:

  • LPIC
  • MySQL
  • Some kind of project management would be nice, any suggestions?