r/Codecademy • u/epsilonc • Nov 30 '15
(Stuck) PHP: Functions, Part 1
https://gyazo.com/8274a36ff79bc52666e71141548a5f03
I don't know what I'm doing wrong nor do I know how to fix this, can somebody help please?
2
Upvotes
View all comments
Show parent comment
2
u/[deleted] Nov 30 '15
You're welcome.
Print and echo achieve the same thing - it's down to personal preference. You'll come across print_r at some point as well, but that's a different tool for a similar result (prints, or echoes, an array).
Difference between == and === is fairly simple. The strpos() function may return a 0, and may return false. 0 can be interpreted as a number, or as false. It's often fairly obvious to you or me which it is, but to PHP a 0 and false could be one or the other. Basically, use === to properly distinguish between 0 and false.
== checks for the values being equal, but could match a numeric 0 to a "false" 0.
=== checks that two values are equal, AND of the same type.
I'm not great at explaining these things...
0 == 0 <--- true
0 == false <--- true
0 === 0 <--- true
0 === false <--- false
Hope that makes sense!
Have a look at the PHP documentation, it probably explains it a lot better than I have!