strpos()
could either return FALSE
, 0, or a non-zero value.
- If the needle occurs at the beginning of the haystack,
strpos()
returns 0. - If it occurs elsewhere, it returns the respective position of the needle in the haystack.
- If needle wasn't found in the haystack,
strpos()
returns booleanFALSE
.
I wasn't checking for strict equality, so the if
statement always returned a falsey value, causing my code to not work.
if ($contains_path = strpos($aspect, '/'))
To fix the issue, you could use !==
, which compares the type and value:
if ($contains_path = (strpos($aspect, '/') !== FALSE))
For more information, check the following links: