ExamVeda
Login
Home
This question belongs to PHP Regular Expressions
Regular Expressions
?

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!";
?>

Answer & Solution
Correct Answer: Option B
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.