Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Sep 13 Previous

Item 547202

You are reviewing the code of one of the juniors and you come across this code fragment:

<?php
...

if ("GET" === $_SERVER["REQUEST_METHOD"]) {
    renderPage();
} else {
    openDbAndSoapConnectionsAndDoOtherHeavyStuff();
}

...
?>

What do you think:

A: Ok, he's using functions.
B: I like that immutable left hand value trick and the use of identity comparison operator.
C: He's showing some potential but I need to take him aside.
D: Looks good to me. It's about lunchtime, I'm thinking club sandwich.

Answer

You better take him aside to explain that he has to expect a whole lot of other requests methods than just GET and POST. Now each HEAD or OPTIONS request for instance will cause heavy stuff to happen on the server. Then assign him to some log file analysis.

So answer C is correct.