PHP PHP Arrays and Control Structures PHP Conditionals Conditionals

Sinead KACHROO
Sinead KACHROO
277 Points

how can we have an if statement with no condition? If just says if ($username) ?

What does this mean?

1 Answer

Steven Parker
Steven Parker
201,932 Points

By itself, an empty string is considered "falsey"; but if the string contains any characters, it will be considered "truthy".

So this test is effectively checking "if $username is not empty".