Thursday, November 19, 2009

switch your case

<?
switch(0) {
case "text": var_dump("casejump"); break;
default: var_dump("default");
}


Output is:
casejump


This is so because 0 == "string" is always true because it converts the string to a number, which results in 0.

No comments:

Post a Comment