I had a discussion with my teacher about the mb_
functions. Whatever, one thing leading to another, we changed the subject and he gave me an example where strpos
and strlen
could be problematic, according to him:
$input = "something"; # input given by the user
$string = "hello"; # string to match
if ( strpos($input, $string) !== false && strlen($input) < strlen($string) ) {
echo "Correct input";
} else {
echo "Incorrect input";
}
(The question is not about how to match 2 strings)
According to my teacher, there may be a way to validate the statement and execute the code echo "Correct input";
.
However, I can't see a flaw in this. Maybe there could be a problem with encoding? Do you have any idea?
okey i think that the flaw will be the if statement logic
how will you use strpos function which check the position of the first occurrence of a substring in a string , and in the same time you want to check if the input is greater than the subject ?
by logic it is impossible