What will be the output of the following PHP code?
<?php
$username = “jasoN”;
if (ereg(“([^a-z])”,$username))
echo “Username must be all lowercase!”;
else
echo “Username is all lowercase!”;
?>
a) Error
b) Username must be all lowercase!
c) Username is all lowercase!
d) No Output is returned
Answer: b
Explanation: Because the provided username is not all lowercase, ereg() will not return FALSE (instead returning the length of the matched string, which PHP will treat as TRUE), causing the message to output.
Related Posts
What would be behaviour if the constructor has a return type?
What would be the behaviour if one parameterized constructor is explicitly defined?
What is not the use of “this” keyword in Java?
What is true about protected constructor?
Abstract class cannot have a constructor.
What is true about constructor?
What is true about Class.getInstance()?
Join The Discussion