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 17 Previous

Item 547208

Consider the following code:

$res = strcmp("a", "b");

What will be the value of $res.

A: true
B: false
C: -1
E: 1


If you ever thought: 'strange: strcmp("equal", "equal") returns false' here's why. strcmp() returns a value that is very much in line with what usort() needs: -1 if the first argument should sort before the second, 1 if it should sort after and if the are equal. So the correct answers is C.

Also note PHP naming inconsistency:

  • strcmp
  • str_replace
  • substr
  • substr_compare
  • substr_replaceli>

PHP has a rich set of string functions but unfortunately there is not much logic in their names. Well you'll say, who cares, we've got code completion and PHP code looks like battle ground anyway. Be warned: there's no code completion at the exam, you've got to learn these inconsequent naming schemes by heart.