35.3 Resolution
So where is the error in the debugger.php file? Figure 35.4 already showed a good hint: In the third line, the $start variable does not have the Boolean value false (as in lines 2, 4, and 6), but the integer value 0. This already solves the puzzle: The character count in strpos() starts at 0. So if a line starts with http://, then strpos($line, "http://") has the return value 0. As a Boolean term, however, 0 corresponds to false. if (0) is therefore equivalent to if (false), so the if branch is not executed. However, if you use the === or !== operator, you will achieve the desired goal as this takes the data type into account and therefore distinguishes between the Boolean false and the integer zero.
So that this is not too ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access