Hi
Can someone please explain why it prints 2?
Code:<?php if ('EMAIL' == 'EMAIL'){ print "1"; }else{ print "2"; } ?>
Thanks
| SitePoint Sponsor |



Hi
Can someone please explain why it prints 2?
Code:<?php if ('EMAIL' == 'EMAIL'){ print "1"; }else{ print "2"; } ?>
Thanks
It shouldnt.
You sure you're copying and pasting correctly?
Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


@cancer10 ; surely you are over-simplifying your code when pasting it here, because I can't see any valid reason to have that sort of IF statement as presented in a production code base.
Can you provide the actual IF statement so we can see the variables in use, how they are assigned, etc? As chances are the problem is you are assuming its value is 'EMAIL' which should equal 'EMAIL' but in all reality it isn't. Have you done a var_dump($var) to see if it really did contain 'EMAIL'?



That IS the actual thing, and I posted it here because I could not find any reason why it would not match. I mean both are simple strings. If you copy/paste my above code and try it on ur end, it will not work.
I just wanna know the reason.
Thanks







Err, wrong terminology on my part, but I'll link to BOM anyway, because it is good to know.
Chances are you have a unicode or similar character hidden there next to the E or after the ' that doesn't show up in ASCII. Just wanted to correct myself, as others would![]()



Thanks for your kind help
Bookmarks