|
Posted by £ukasz Hejnak on 12/18/05 19:17
Erik Johnson napisaΕ(a):
> Okay.. I was just wondering; What's the difference between = and ==? Would
> it matter if I changed them? It seems as though if I put = instead of the
> =='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
> instead of =='s, then it comes up with only page one no matter what $page
> equals.
It's a *BIG* difference!
Because single '=' means that whatever stands at the right side of the
'=' should be assigned to whatever stands at the left side,
ie.
$a=5
doesn't compare if a is equal 5, only assignes the variable 'a' it's
value which will be 5 after this code
so if You write
if ($a=5) {...}
it will always be executed (therefore else isn't executed), as
assignment always returns true :]
so when using 'if' You always need to do
if ($a==5) {...}
unless of course Youd want to do an assingment and some code, but then
why not do
$a=5;
....
? :)
--
Best wishes
Εukasz 'Szift' Hejnak
[Back to original message]
|