Conditional Statement (Mistake 3)

Refer to the following codes:

  1. <?php
  2. $password = "ABCDE12345";
  3. $count = strlen($password); //strlen is a PHP function to calculate how many characters in the variable
  4. if ($count < 5);
  5. echo "The password length must be 5 characters and above.";
  6. if (strlen($name) >= 5)
  7. echo "Your password is accepted!";
  8. ?>

It should output "Your password is accepted" since the password length is 10 characters. However, the code's output is "The password length must be 5 characters and above.". Try to fix the codes.  Be the one who posts a comment describing what is the mistake with the codes.


Last modified: Saturday, 23 February 2019, 10:11 AM