> [EMAIL PROTECTED] wrote:
> >>Ok i found something very interesting
> >>, i have a session var setup to check for a groupID which is an
> >>integer,
> >>
> >>if ($_SESSION['groupID']==1) { this was working, then when 
> i changed it
> >>to
> >>
> >>if ($_SESSION['groupID']===1) { per recomendation, it does 
> not now ! i
> >>was going through my code and changing things, now i fear it may all
> >>break ?
> >>
> > 
> > 
> > I changed it to if ($_SESSION['groupID']==='1') { and it 
> worked, why was
> > that, is what i did before bad practice ?
> > 
> 
> I think $_SESSION['groupID'] here is considered a string, 
> which is going 
> to evaluate to 0 (zero) in comparisons.  Hence 0 === 1 will return 
> false.  However, when you enclose the 1 in quotes, it becomes 
> a string 
> too for comparison, and will evaluate to 0.  Someone correct 
> me if I am 
> mistaken.

I think the first bit of what you're saying is right, but when '1' is used,
then a string comparison between '0' === '1' is done since both are now
strings (or am I mistaken?).

Martin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to