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 is it called where object has its own lifecycle and child object cannot belong to another parent object?
When does method overloading is determined?
What is it called if an object has its own lifecycle and there is no owner?
Method overriding is combination of inheritance and polymorphism?
When Overloading does not occur?
Which of the following is not OOPS concept in Java?
How can we identify whether a compilation unit is class or interface from a .class file?
Join The Discussion