php Cheat Sheet
28 de Maio de 2009, 0:00
, por Software Livre Brasil
|
Ninguém está seguindo este artigo ainda.
Empty() & Co, Special Values
|
gettype() |
empty() |
is_null() |
isSet() |
(bool) |
$x = “”; |
string |
true |
false |
true |
false |
$x = null; |
NULL |
true |
true |
false |
false |
var $x; (not set) |
NULL |
true |
true |
false |
false |
$x = array(); |
array |
true |
false |
true |
false |
$x = false; |
boolean |
true |
false |
true |
false |
$x = 15; |
integer |
false |
false |
true |
true |
$x = 1; |
integer |
false |
false |
true |
true |
$x = 0; |
integer |
true |
false |
true |
false |
$x = -1; |
integer |
false |
false |
true |
true |
$x = “15″; |
string |
false |
false |
true |
true |
$x = “1″; |
string |
false |
false |
true |
true |
$x = “0″; |
string |
true |
false |
true |
false |
$x = “-1″; |
string |
false |
false |
true |
true |
$x = “foo”; |
string |
false |
false |
true |
true |
$x = “true”; |
string |
false |
false |
true |
true |
$x = “false”; |
string |
false |
false |
true |
true |
Note: empty() and isSet() don’t give a warning when the variable has not been defined before.
comparison with ==
|
true |
false |
1 |
0 |
-1 |
“1″ |
“0″ |
“-1″ |
“1.3″ |
“1.30″ |
1.3 |
1.30 |
array() |
“foo” |
“” |
true |
true |
false |
true |
false |
true |
true |
false |
true |
true |
true |
true |
true |
false |
true |
false |
false |
false |
true |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
true |
false |
true |
1 |
true |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
0 |
false |
true |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
true |
true |
-1 |
true |
false |
false |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
“1″ |
true |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
“0″ |
false |
true |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
“-1″ |
true |
false |
false |
false |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
“1.3″ |
true |
false |
false |
false |
false |
false |
false |
false |
true |
true |
true |
true |
false |
false |
false |
“1.30″ |
true |
false |
false |
false |
false |
false |
false |
false |
true |
true |
true |
true |
false |
false |
false |
1.3 |
true |
false |
false |
false |
false |
false |
false |
false |
true |
true |
true |
true |
false |
false |
false |
1.30 |
true |
false |
false |
false |
false |
false |
false |
false |
true |
true |
true |
true |
false |
false |
false |
array() |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
“foo” |
true |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
“” |
false |
true |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
comparison with ===
|
true |
false |
1 |
0 |
-1 |
“1″ |
“0″ |
“-1″ |
“1.3″ |
“1.30″ |
1.3 |
1.30 |
array() |
“foo” |
“” |
true |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
1 |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
0 |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
-1 |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
“1″ |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
false |
“0″ |
false |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
false |
“-1″ |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
false |
“1.3″ |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
false |
“1.30″ |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
false |
false |
false |
1.3 |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
true |
false |
false |
false |
1.30 |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
true |
false |
false |
false |
array() |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
false |
“foo” |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
false |
“” |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
false |
true |
by: http://www.blueshoes.org/en/developer/php_cheat_sheet/
0sem comentários ainda