<<< Previous question <<< Question ID#0420.md >>> Next question >>>
One way to compare strings in PHP is by using the strcmp() function. This is useful since not only can you determine if two strings are equal, but you can also test if one string is 'greater than' the other (using the corresponding ASCII values in each character comparison). What is the output of the following PHP script?
$test1聽=聽strcmp('hello',聽"hello");
$test2聽=聽strcmp("Hello",聽"hello");
$test3聽=聽strcmp('60',聽'500');
if聽($test1聽==聽0)聽聽聽聽聽{聽echo聽"a";聽}
else聽if聽($test1聽<聽0)聽{聽echo聽"b";聽}
else聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽echo聽"c";聽}
if聽($test2聽==聽0)聽聽聽聽聽{聽echo聽"d";聽}
else聽if聽($test2聽<聽0)聽{聽echo聽"e";聽}
else聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽echo聽"f";聽}
if聽($test3聽==聽0)聽聽聽聽聽{聽echo聽"g";聽}
else聽if聽($test3聽<聽0)聽{聽echo聽"h";聽}
else聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽echo聽"i";聽}Enter the exact script output
- A) aei
- B) a
- C) iuo
- D) bei
Answer
Answer: A