Hello Reader's ,
Today on My blog, You will learn how to compare string length in PHP.
PHP provides strlen() function which compares two string length is equivalent to each other. The strlen() function returns the length of a string on success, and if the string is empty then it will return 0.
<?php
public function password_check($value)
{
if(strlen($value) < 8)
{
echo "The password is too short";
}elseif(strlen($value) > 10)
{
echo "The password is too long";
}else{
echo "The password is the proper length";
}
}
password_check("pass");
password_check("password@123");
password_check("password");
In the above example, we are passing some parameter to password_check () function which checks the length of the string
I hope this will help you. Please feel free to give us your feedback in comments.
0 Comment(s)