Incredible India - a PHP adventure - Part5

From yesterday I want to share this live ASCII stream from Chennai/India:

schalalalaal dem de issum her de issum ooohaaa
de issum
chaka chakk boom chaka chak boom
ill fort me uh oohhh de aahhaaaaa
il like me dal uh fort me da ahahahhhh
na mek dehurt ahaaa

This is what I streamed yesterday evening from my balkonee to Marco. A live indian concert. There was a performance at my hotel and I tried to let him ‘hear’ it.

Unfortunately my eee went mad. After continuing transmitting the text the keyboard had failures and inserted additional keystrokes. The result looked like this:

LKET’s b]ikg set da LAAAAA
sikt me b]ik.]ik.k]ik da de ]ikssum
da de de ]issum !
come ‘okn
da de ]ikssum

So I had to stop my ASCII concert ;) - and went to bed.

Today is the day. finally we will meet possible candidates and have the chance to talk to them - and test them. First I tought about executing the ZEND tests ( you know the demo tests ) but we finally decided to write our own test. Unfortunately I can’t post it here as there are many questions which I use also for new employees in lithuania and germany. They could cheat. So we will stay a bit vague - but hey - life is boring without our little secrets.

Half the day passed taking executing the tests and gathering the results. Today we tested only a few junior developers. The results here were not so good but this simply means that these people which we tested have not much know how about PHP and mySQL (but please take into account that we’ve tested junior developers - not seniors). I do believe that they can learn and catch up fast.

That you can get an impression what we’ve tested I let you lurk into some of the questions. What do you think? Too difficult? For juniors definitely. Maybe we expected to much?

Feel free to answer them in a comment ;)

1.What will be printed?

$a = array(false => 'a', true => 'b', 0=> 'c');
print_r($a);

2.What will be printed?

print count(2);

3.What will be printed?

print count(null);

4.What will be printed?

$fruits = array('lemon', 'orange'); 
 
foreach ($fruits as $k => $v) {
    $v .= ' is good';
} 
 
print_r($fruits);

5.What will be printed?

$a = array(1, true, null); 
 
print isset($a[2]) ? 'element is set' : 'element is not set';

6.What will be printed?

$a = "abcde"; 
 
print $a[2] . $a{2};

7.What will be printed?

class Car
{
    protected $color = 'transparent'; 
 
    public function getColor()
    {
       return $this->color;
    }
} 
 
class Jaguar extends Car
{
    private $color = 'green';
} 
 
$car = new Jaguar(); 
 
print $car->getColor();

Post me the answers please ;)

And let me share some indian wisdom:

“Really good, really good - Questions where easy only the answers were difficult”

Later we went to another fabulous dinner - Indian food offers a great variety of many different tastes and kitchens. Don’t forget that india is as large as whole europe and only with this you can compare it.
Some sort of Barbecue - very soft meat - amazing! And again I tried to support local Airline Industry as good as I could.

After rushing home we watched the game. They bring EM in public TV as there are many people interested in it. At least I tried. Actually always when it was really interesting the picture disappeared. Heard that this happend in germany also. Luckily there is internet radio so I did not miss something.

I do believe that austrians did this intentionally as a revenge. Could be or?

I feel a bit dizzy today, Game was over 02:20 in the morning. And sleeping is not so easy when you have between 26 and 30 degrees in your room.

Let met close with a bit of multimedia. This ad is not a joke - it’s serious. And it describes the spirit of india very well. Have a look it’s worth it.

Have fun ;)

Comments

5 Responses to “Incredible India - a PHP adventure - Part5”

  1. Marco on June 26th, 2008 4:27 pm

    my solutions:
    1. 0 => c ; 1 => b
    2. 1
    3. 0
    4. array(’lemon’, ‘orange’)
    5. element is not set
    6. cc
    7. PHP Fatal error: Access level to Jaguar::$color must be protected …

  2. Tomas Liubinas on June 26th, 2008 7:19 pm

    Hehe, congratulations on german victory. It was really nice game to watch.

    Hmm a bit tricky questions, but here’s my try:
    1. 1 => b, 0 => c
    2. 0
    3. 0
    4. array(’lemon’, ‘orange’);
    5. ‘element is set’
    6. c abcde 2 (no spaces) ???
    7. fatal error

  3. audrys on June 27th, 2008 7:32 am

    hi guys,
    congratulations to Marco :) if it was you and not php executable who answered the questions, then you scored very well.

    Tomas, your try was good as well, but probably you had too much beer before :)

    Actually i would consider that only questions 6 and 7 require some deeper knowledge of php. If you never come across the fact you can access characters of the string by [] or {}, then question 6 is tricky. Question 7 is an advanced one, more about theory, you cannot reduce visibility of an attribute in derived classes.

    The rest of the questions are not complicated, one must have some intermediate knowledge of php and, of course, PRACTICAL EXPERIENCE to answer them.

    So let’s review the rest if the questions :)

    No.1: There are only two types of array keys in php. String or integer. Boolean values are converted to integer: false to 0 and true to 1. If there happens to be an element with the same key, overwriting occurs.

    No.2: count() function. Probably the most widely used function in php, so you should know how it behaves :) count() behaviour depends upon the type of parameter:
    count(null) is always 0;
    count() is always the number of elements in an array;
    count() is always 1;

    No.3: simple, right? :)

    No.4: tests if you know how foreach works. When it does a copy of array and when it operates on real same array.

    No.5: ah, common mistake. isset(null) is always false. So to check if there is an array element with given key, you need use array_key_exists() instead of isset()

    So not so difficult, isn’t it? :)

  4. Tomas Liubinas on June 27th, 2008 3:55 pm

    Audrys, thanks for the explanation. It must be useful when you want to know did the candidate ever tried to count() non array types ;)

  5. audrys on June 28th, 2008 12:46 pm

    Yeah, yeah, some of these questions are ’strange’ and not for beginners, and don’t forget that they are just a part of the interview. Nevertheless, during interviews such questions and further discussions about answers reveal knowledge of the candidate quite well, and there were developers who scored quite well.

Leave a Reply