FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » A little tip
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: A little tip [message #177481 is a reply to message #177445] Mon, 02 April 2012 07:42 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 30/03/2012 19:02, Shelly escribió/wrote:
> Here is something I jist came across, so I am passing it on:
> ==========
> $val= TRUE;
> $val &= TRUE;
> print ($val === TRUE) ? "Triple is true\n" : "Triple is false\n";
> print ($val == TRUE) ? "Double is true\n" : "Double is false\n";
>
> Results in:
> Triple is false
> Double is true
> ==========
>
> Who designed that? It is totally counter-intuitive.

When trying to understand these subtleties, I find var_dump() more
useful than plain echos. In this case:

$val= TRUE;
var_dump($val);
$val &= TRUE;
var_dump($val);

.... prints:

bool(true)
int(1)

.... which makes the result of loose and strict comparisons obvious.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: session variable doesn't appear in side bar
Next Topic: Doubt regarding an array of references...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 20:41:13 GMT 2024

Total time taken to generate the page: 0.04200 seconds