PHP Variable Testing
Important notes on the comparisons and tests:
- There appear to be two null values at the start of the test. The first one is actually an unset variable, i.e. no longer in existence. The second is a variable which was set to null.
- Tests with Ctype and strcmp-type functions use the system default C locale. Results may vary for other locales.
- Some tests might seem a bit ‘silly’, for instance testing with
=== 'null'
. The reason for adding these tests can be divided into two categories:- Data received from databases and $_POST/$_GET/etc variables are always received as strings (unless a potentially used database abstraction layer changes this). So sometimes testing for a string value where a non-string variable type would be more logical, can actually make sense.
- Some are unfortunately regularly encountered in code and added here to illustrate why not to use them.
- BEWARE: some variable changing functions will not return a changed value, but will return whether the changing succeeded. You will find this indicated in the function header by the use of
$copy
(as the test will use a copy of the variable to not influence the other tests in the same table).
Notes on some variables:
Some of the test variables used, do not print the way they are set, either because they contain invisible characters or because they result in something else, so for your convenience, these are outlined here:
† | How the variable is defined: |
---|---|
i8 | $x = 0xCC00F9; // Hexadecimal integer. |
i9 | $x = 052; // Octal integer. |
ia | $x = 0b0111001; // Binary integer (PHP5.4+). |
ib | $x = ௫; // Tamil digit five - entered as string as PHP itself cannot deal with it as an integer. |
ic | $x = ⁸₈; // Unicode superscript and subscript digit 8 - entered as a string as PHP itself cannot deal with these as integers. |
f5 | $x = acos(8); // = NAN |
f6 | $x = NAN; // = Not a number. |
f7 | $x = log(0); // = Infinite. |
f8 | $x = INF; // = Infinite. |
f9 | $x = 1.2345E8; // Exponent notation float. |
fa | $x = ⅕; // Unicode character representing 1/5 - entered as string as PHP itself cannot deal with it as a float. |
sk | $x = "123, \"str\"\r\n"; |
sn | $x = "\f\t\r\n"; |
sp | $x = "\x7f\t\r\n" |
Legend / How to use the tables:
- The error level for this test sheet has been set to
E_ALL & ~E_STRICT
. All errors are caught and referenced (with #links) in the tables with details of the error messages (if any) below each table. Similar error messages are grouped together for your convenience. - Some column labels have been shortened to avoid them taking undue space. These are indicated by a
…
. If you mouse-over the column label you will see the full variable/test information. - In comparison tables, the left-top table header will indicate the comparison used and link to the relevant page in the PHP Manual.
- In test tables, the left top table header indicates the type of tests. Both this header as well as most column headers link to their respective relevant PHP Manual pages.
- A ‡ with a number next to a column header means there is a (linked) footnote for that entry at the bottom of the page.
- When you mouse-over the table the row and column you are at are highlighted. To help you compare specific columns/rows, you can click on any cell to mark the column and row which the cell intersects for extra highlighting. Click again to remove this sticky highlight.
Legend to the color coding
NULL: | null |
---|---|
Boolean: | true / false |
Integer: | 123456789 / 0 |
Float: | 12345.6789 |
String: | ‘A string’ |
Array and Object: | Indicated as such. Array keys, array values and object properties will be color coded according to the coding shown here. |
Resources: | Resource id #40 |
- General typing
- is_…()
- Null
- Boolean
- Integers
- Floats
- Numeric tests
- String casting
- String tests
- Array casting
- Array testing
- Objects
- Resources
- Basic Arithmetic
- CType Extension
- Filter Extension - bool/int/float
- Filter Extension - string
General typing | gettype() | empty() | is_null() | isset() | (bool) | if( $x ) {..} | General typing |
---|---|---|---|---|---|---|---|
General typing | gettype() | empty() | is_null() | isset() | (bool) | if( $x ) {..} | General typing |
$x = null : ( = NULL ) |
‘NULL’ | true | true | false | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
‘NULL’ | true | true | false | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
‘boolean’ | true | false | true | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
‘boolean’ | false | false | true | true | true | $x = bool : 1 ( = true ) |
$x = int : 1 |
‘integer’ | false | false | true | true | true | $x = int : 1 |
$x = int : 0 |
‘integer’ | true | false | true | false | false | $x = int : 0 |
$x = int : -1 |
‘integer’ | false | false | true | true | true | $x = int : -1 |
$x = int : 42 |
‘integer’ | false | false | true | true | true | $x = int : 42 |
†i8$x = int : 13369593 |
‘integer’ | false | false | true | true | true | †i8$x = int : 13369593 |
†i9$x = int : 42 |
‘integer’ | false | false | true | true | true | †i9$x = int : 42 |
$x = float : 1.3 |
‘double’ | false | false | true | true | true | $x = float : 1.3 |
$x = float : 0.005 |
‘double’ | false | false | true | true | true | $x = float : 0.005 |
$x = float : 0 |
‘double’ | true | false | true | false | false | $x = float : 0 |
$x = float : -1.3 |
‘double’ | false | false | true | true | true | $x = float : -1.3 |
†f5$x = float : NAN |
‘double’ | true | false | true | false | false | †f5$x = float : NAN |
†f6$x = float : NAN |
‘double’ | true | false | true | false | false | †f6$x = float : NAN |
†f7$x = float : -INF |
‘double’ | false | false | true | true | true | †f7$x = float : -INF |
†f8$x = float : INF |
‘double’ | false | false | true | true | true | †f8$x = float : INF |
†f9$x = float : 123450000 |
‘double’ | false | false | true | true | true | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
‘string’ | true | false | true | false | false | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
‘string’ | false | false | true | true | true | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
‘string’ | false | false | true | true | true | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
‘string’ | false | false | true | true | true | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
‘string’ | false | false | true | true | true | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
‘string’ | true | false | true | false | false | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
‘string’ | false | false | true | true | true | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
‘string’ | false | false | true | true | true | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
‘string’ | false | false | true | true | true | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
‘string’ | false | false | true | true | true | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
‘string’ | false | false | true | true | true | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
‘string’ | false | false | true | true | true | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
‘string’ | false | false | true | true | true | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
‘string’ | false | false | true | true | true | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
‘string’ | false | false | true | true | true | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
‘string’ | false | false | true | true | true | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
‘string’ | false | false | true | true | true | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
‘string’ | false | false | true | true | true | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
‘string’ | false | false | true | true | true | $x = string[4] : ‘0123’ |
$x = array() |
‘array’ | true | false | true | false | false | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
‘array’ | false | false | true | true | true | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
‘array’ | false | false | true | true | true | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
‘object’ | false | false | true | true | true | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
‘object’ | false | false | true | true | true | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #42 ( = RESOURCE ) |
‘resource’ | false | false | true | true | true | $x = resource : Resource id #42 ( = RESOURCE ) |
- Notice: Undefined index: notset
is_…() | gettype() | is_null() | is_scalar() | is_bool() | is_int() | is_float() | is_string() | is_array() | is_object() | is_resource() | is_callable() | is_numeric() | is_iterable() | is_countable() | is_…() |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is_…() | gettype() | is_null() | is_scalar() | is_bool() | is_int() | is_float() | is_string() | is_array() | is_object() | is_resource() | is_callable() | is_numeric() | is_iterable() | is_countable() | is_…() |
$x = null : ( = NULL ) |
‘NULL’ | true | false | false | false | false | false | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
‘NULL’ | true | false | false | false | false | false | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
‘boolean’ | false | true | true | false | false | false | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
‘boolean’ | false | true | true | false | false | false | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = bool : 1 ( = true ) |
$x = int : 1 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = int : 1 |
$x = int : 0 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = int : 0 |
$x = int : -1 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = int : -1 |
$x = int : 42 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = int : 42 |
†i8$x = int : 13369593 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †i8$x = int : 13369593 |
†i9$x = int : 42 |
‘integer’ | false | true | false | true | false | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †i9$x = int : 42 |
$x = float : 1.3 |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = float : 1.3 |
$x = float : 0.005 |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = float : 0.005 |
$x = float : 0 |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = float : 0 |
$x = float : -1.3 |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = float : -1.3 |
†f5$x = float : NAN |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †f5$x = float : NAN |
†f6$x = float : NAN |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †f6$x = float : NAN |
†f7$x = float : -INF |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †f7$x = float : -INF |
†f8$x = float : INF |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †f8$x = float : INF |
†f9$x = float : 123450000 |
‘double’ | false | true | false | false | true | false | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘is_array’ |
‘string’ | false | true | false | false | false | true | false | false | false | true | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[8] : ‘is_array’ |
$x = string[8] : ‘0xCC00F9’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
‘string’ | false | true | false | false | false | true | false | false | false | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = string[4] : ‘0123’ |
$x = array() |
‘array’ | false | false | false | false | false | false | true | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
‘array’ | false | false | false | false | false | false | true | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
‘array’ | false | false | false | false | false | false | true | false | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
‘object’ | false | false | false | false | false | false | false | true | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
‘object’ | false | false | false | false | false | false | false | true | false | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #45 ( = RESOURCE ) |
‘resource’ | false | false | false | false | false | false | false | false | true | false | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | $x = resource : Resource id #45 ( = RESOURCE ) |
- Notice: Undefined index: notset
Null | settype ( $copy, 'null' ) | (unset) | unset() | CastToType::_null ( $x ) ‡1 | isset() | empty() | is_null() | == null | === null | == 'null' | === 'null' | Null |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Null | settype ( $copy, 'null' ) | (unset) | unset() | CastToType::_null ( $x ) ‡1 | isset() | empty() | is_null() | == null | === null | == 'null' | === 'null' | Null |
$x = null : ( = NULL ) |
null | null | null
( #2 ) |
null | false | true | true | true | true | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
null | null | null
( #2 ) |
null | false | true | true | true | true | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
null | null | null
( #2 ) |
null | true | true | false | true | false | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | true | false | $x = bool : 1 ( = true ) |
$x = int : 1 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = int : 1 |
$x = int : 0 |
null | null | null
( #2 ) |
null | true | true | false | true | false | true | false | $x = int : 0 |
$x = int : -1 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = int : -1 |
$x = int : 42 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = int : 42 |
†i8$x = int : 13369593 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | †i8$x = int : 13369593 |
†i9$x = int : 42 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | †i9$x = int : 42 |
$x = float : 1.3 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = float : 1.3 |
$x = float : 0.005 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = float : 0.005 |
$x = float : 0 |
null | null | null
( #2 ) |
null | true | true | false | true | false | true | false | $x = float : 0 |
$x = float : -1.3 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = float : -1.3 |
†f5$x = float : NAN |
null | null | null
( #2 ) |
null | true | true | false | true | false | true | false | †f5$x = float : NAN |
†f6$x = float : NAN |
null | null | null
( #2 ) |
null | true | true | false | true | false | true | false | †f6$x = float : NAN |
†f7$x = float : -INF |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | †f7$x = float : -INF |
†f8$x = float : INF |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
null | null | null
( #2 ) |
null | true | true | false | true | false | false | false | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
null | null | null
( #2 ) |
null | true | true | false | false | false | false | false | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | true | true | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = string[4] : ‘0123’ |
$x = array() |
null | null | null
( #2 ) |
null | true | true | false | true | false | false | false | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #48 ( = RESOURCE ) |
null | null | null
( #2 ) |
null | true | false | false | false | false | false | false | $x = resource : Resource id #48 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Notice: Undefined variable: x
Uses an external library
Boolean | settype ( $copy, 'bool' ) | (bool) | filter_var (…) | filter_var (…) ‡1 ‡2 | CastToType::_bool ( $x, false, false ) ‡3 | is_bool() | == true | === true | == 1 | == 'true' | == false | === false | == 0 | == 'false' | if( $x ) {..} | if( ! $x ) {..} | Boolean |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Boolean | settype ( $copy, 'bool' ) | (bool) | filter_var (…) | filter_var (…) ‡1 ‡2 | CastToType::_bool ( $x, false, false ) ‡3 | is_bool() | == true | === true | == 1 | == 'true' | == false | === false | == 0 | == 'false' | if( $x ) {..} | if( ! $x ) {..} | Boolean |
$x = null : ( = NULL ) |
false | false | false | null | null | false | false | false | false | false | true | false | true | false | false | true | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | false | false | null | null | false | false | false | false | false | true | false | true | false | false | true | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | false | false | null | false | true | false | false | false | false | true | true | true | false | false | true | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
true | true | true | true | true | true | true | true | true | true | false | false | false | true | true | false | $x = bool : 1 ( = true ) |
$x = int : 1 |
true | true | true | true | true | false | true | false | true | false | false | false | false | false | true | false | $x = int : 1 |
$x = int : 0 |
false | false | false | false | false | false | false | false | false | true | true | false | true | true | false | true | $x = int : 0 |
$x = int : -1 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = int : -1 |
$x = int : 42 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = int : 42 |
†i8$x = int : 13369593 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | †i8$x = int : 13369593 |
†i9$x = int : 42 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | †i9$x = int : 42 |
$x = float : 1.3 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = float : 1.3 |
$x = float : 0.005 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = float : 0.005 |
$x = float : 0 |
false | false | false | false | false | false | false | false | false | true | true | false | true | true | false | true | $x = float : 0 |
$x = float : -1.3 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = float : -1.3 |
†f5$x = float : NAN |
false | false | false | null | null | false | false | false | true | true | true | false | true | true | false | true | †f5$x = float : NAN |
†f6$x = float : NAN |
false | false | false | null | null | false | false | false | true | true | true | false | true | true | false | true | †f6$x = float : NAN |
†f7$x = float : -INF |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | †f7$x = float : -INF |
†f8$x = float : INF |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
false | false | false | null | null | false | false | false | false | false | true | false | true | false | false | true | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
true | true | false | null | null | false | true | false | false | false | false | false | true | false | true | false | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
true | true | true | true | true | false | true | false | true | false | false | false | false | false | true | false | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
true | true | true | true | true | false | true | false | true | false | false | false | false | false | true | false | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
false | false | false | false | false | false | false | false | false | false | true | false | true | false | false | true | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
true | true | false | null | null | false | true | false | false | false | false | false | true | false | true | false | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
true | true | true | true | true | false | true | false | false | true | false | false | true | false | true | false | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
true | true | false | false | false | false | true | false | false | false | false | false | true | true | true | false | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
true | true | false | null | null | false | true | false | false | false | false | false | true | false | true | false | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
true | true | false | null | null | false | true | false | false | false | false | false | true | false | true | false | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[10] : ‘123, "str"’ |
$x = string[2] : ‘on’ |
true | true | true | true | true | false | true | false | false | false | false | false | true | false | true | false | $x = string[2] : ‘on’ |
$x = string[3] : ‘off’ |
true | true | false | false | false | false | true | false | false | false | false | false | true | false | true | false | $x = string[3] : ‘off’ |
$x = string[3] : ‘yes’ |
true | true | true | true | true | false | true | false | false | false | false | false | true | false | true | false | $x = string[3] : ‘yes’ |
$x = string[2] : ‘no’ |
true | true | false | false | false | false | true | false | false | false | false | false | true | false | true | false | $x = string[2] : ‘no’ |
$x = string[8] : ‘0xCC00F9’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = string[4] : ‘0123’ |
$x = array() |
false | false | array() |
array() |
null | false | false | false | false | false | true | false | false | false | false | true | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
true | true | Array: ( [1] => b false ) |
Array: ( [1] => null ) |
Array: ( [1] => null ) |
false | true | false | false | false | false | false | false | false | true | false | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
true | true | Array: ( [0] => b false [1] => b true [2] => b false [3] => b false [4] => b false [5] => b false ) |
Array: ( [0] => null [1] => b true [2] => null [3] => null [4] => null [5] => null ) |
Array: ( [0] => b false [1] => b true [2] => null [3] => null [4] => null [5] => null ) |
false | true | false | false | false | false | false | false | false | true | false | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
true | true | false | false | null | false | true | false | true
( #2 ) |
false | false | false | false
( #2 ) |
false | true | false | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
true | true | false | null | null | false | true | false | true
( #2 ) |
false | false | false | false
( #2 ) |
false | true | false | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #53 ( = RESOURCE ) |
true | true | false | null | null | false | true | false | false | false | false | false | false | false | true | false | $x = resource : Resource id #53 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to int
Please note: On some PHP versions filter_var( $x, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE )
where $x = false
will incorrectly return null
.
Also: with the same parameters filter_var() will return false
instead of null
for most objects.
The code snippet is simplified for brevity. Please refer to the source of this file on GitHub for full details on how to use filter_var_array().
Uses an external library
Integers | settype ( $copy, 'int' ) | (int) | intval() | $x + 0 | filter_var (…) | filter_var (…) ‡1 | CastToType::_int ( $x, false, false ) ‡2 | abs() | empty() | is_int() | is_numeric() | ctype_digit() ‡3 | preg_match (`^[0-9]+$`) | preg_match (`^[0-9-]+$`) | preg_match (`^[\p{N}-]+$`u) | Integers |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Integers | settype ( $copy, 'int' ) | (int) | intval() | $x + 0 | filter_var (…) | filter_var (…) ‡1 | CastToType::_int ( $x, false, false ) ‡2 | abs() | empty() | is_int() | is_numeric() | ctype_digit() ‡3 | preg_match (`^[0-9]+$`) | preg_match (`^[0-9-]+$`) | preg_match (`^[\p{N}-]+$`u) | Integers |
$x = null : ( = NULL ) |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
true | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
true | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
true | false | false | false | false | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
1 | 1 | 1 | 1 | 1 | 1 | null | 1 |
false | false | false | false | true | true | true | $x = bool : 1 ( = true ) |
$x = int : 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
false | true | true | false | true | true | true | $x = int : 1 |
$x = int : 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
true | true | true | false | true | true | true | $x = int : 0 |
$x = int : -1 |
-1 | -1 | -1 | -1 | -1 | -1 | -1 | 1 |
false | true | true | false | false | true | true | $x = int : -1 |
$x = int : 42 |
42 | 42 | 42 | 42 | 42 | 42 | 42 | 42 |
false | true | true | false | true | true | true | $x = int : 42 |
†i8$x = int : 13369593 |
13369593 | 13369593 | 13369593 | 13369593 | 13369593 | 13369593 | 13369593 | 13369593 |
false | true | true | true | true | true | true | †i8$x = int : 13369593 |
†i9$x = int : 42 |
42 | 42 | 42 | 42 | 42 | 42 | 42 | 42 |
false | true | true | false | true | true | true | †i9$x = int : 42 |
†ib$x = string[3] : ‘௫’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | true | †ib$x = string[3] : ‘௫’ |
†ic$x = string[6] : ‘⁸₈’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | true | †ic$x = string[6] : ‘⁸₈’ |
$x = float : 1.3 |
1 | 1 | 1 | 1.3 | b false |
null | null | 1.3 | false | false | true | false | false | false | false | $x = float : 1.3 |
$x = float : 0.005 |
0 | 0 | 0 | 0.005 | b false |
null | null | 0.005 | false | false | true | false | false | false | false | $x = float : 0.005 |
$x = float : 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | true | false | true | false | true | true | true | $x = float : 0 |
$x = float : -1.3 |
-1 | -1 | -1 | -1.3 | b false |
null | null | 1.3 | false | false | true | false | false | false | false | $x = float : -1.3 |
†f5$x = float : NAN |
0 | 0 | 0 | NAN | b false |
null | null | NAN | true | false | true | false | false | false | false | †f5$x = float : NAN |
†f6$x = float : NAN |
0 | 0 | 0 | NAN | b false |
null | null | NAN | true | false | true | false | false | false | false | †f6$x = float : NAN |
†f7$x = float : -INF |
0 | 0 | 0 | -INF | b false |
null | null | INF | false | false | true | false | false | false | false | †f7$x = float : -INF |
†f8$x = float : INF |
0 | 0 | 0 | INF | b false |
null | null | INF | false | false | true | false | false | false | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
123450000 | 123450000 | 123450000 | 123450000 | 123450000 | 123450000 | 123450000 | 123450000 | false | false | true | false | true | true | true | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
true | false | false | false | false | false | false | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | false | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
false | false | true | false | false | false | false | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
false | false | false | false | false | false | false | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
false | false | true | true | true | true | true | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
true | false | true | true | true | true | true | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
-1 | -1 | -1 | -1 | -1 | -1 | -1 | 1 |
false | false | true | false | false | true | true | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
42 | 42 | 42 | 42 | 42 | 42 | 42 | 42 |
false | false | true | true | true | true | true | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
1 | 1 | 1 | 1.3 | b false |
null | null | 1.3 | false | false | true | false | false | false | false | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 | false | false | true | false | false | false | false | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
-1 | -1 | -1 | -1.305 | b false |
null | null | 1.305 | false | false | true | false | false | false | false | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | false | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | false | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | false | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
123 | 123 | 123 | 123 | b false |
null | null | 123 |
false | false | false | false | false | false | false | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
0 | 0 | 0 | 0 | b false |
null | null | 0 |
false | false | false | false | false | false | false | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
123 | 123 | 123 | 123 | b false |
null | null | 123 |
false | false | false | false | false | false | false | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
0 | 0 | 0 | 13369593 | b false |
null | null | 13369593 |
false | false | true | false | false | false | false | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
123 | 123 | 123 | 123 | b false |
null | 123 | 123 |
false | false | true | true | true | true | true | $x = string[4] : ‘0123’ |
$x = array() |
0 | 0 | 0 | Fatal error ( #2 ) |
array() |
array() |
null | b false |
true | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
1 | 1 | 1 | Fatal error ( #2 ) |
Array: ( [1] => b false ) |
Array: ( [1] => null ) |
Array: ( [1] => null ) |
b false |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
1 | 1 | 1 | Fatal error ( #2 ) |
Array: ( [0] => b false [1] => 1 [2] => b false [3] => b false [4] => b false [5] => b false ) |
Array: ( [0] => null [1] => 1 [2] => null [3] => null [4] => null [5] => null ) |
Array: ( [0] => null [1] => 1 [2] => null [3] => null [4] => null [5] => null ) |
b false |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
b false |
b false |
null | 1 ( #4 ) |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
b false |
null | null | 1 ( #4 ) |
false | false | false | false | false | false | false | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #56 ( = RESOURCE ) |
56 | 56 | 56 | 56 | b false |
null | null | 56 |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = resource : Resource id #56 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Fatal error: Unsupported operand types
- Warning: preg_match() expects parameter 2 to be string, array/object/resource given
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to int
The code snippet is simplified for brevity. Please refer to the source of this file on GitHub for full details on how to use filter_var_array().
Uses an external library
Important: Integers between -128 and 255 are interpreted as the ASCII value pointing to a character (negative values have 256 added in order to allow characters in the Extended ASCII range).
In any other case, integers are interpreted as a string containing the decimal digits of the integer.
Floats | settype ( $copy, 'float' ) | (float) | floatval() | $x + 0.0 | filter_var (…) | filter_var (…) ‡1 | CastToType::_float ( $x, false, false ) ‡2 | empty() | is_float() | is_numeric() | ctype_digit() ‡3 | preg_match (`^[0-9\.]+$`) | preg_match (`^[0-9\.-]+$`) | preg_match (`^[\p{N}\.-]+$`u) | Floats |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Floats | settype ( $copy, 'float' ) | (float) | floatval() | $x + 0.0 | filter_var (…) | filter_var (…) ‡1 | CastToType::_float ( $x, false, false ) ‡2 | empty() | is_float() | is_numeric() | ctype_digit() ‡3 | preg_match (`^[0-9\.]+$`) | preg_match (`^[0-9\.-]+$`) | preg_match (`^[\p{N}\.-]+$`u) | Floats |
$x = null : ( = NULL ) |
0 | 0 | 0 | 0 | b false |
null | null | true | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
0 | 0 | 0 | 0 | b false |
null | null | true | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
0 | 0 | 0 | 0 | b false |
null | null | true | false | false | false | false | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
1 | 1 | 1 | 1 | 1 | 1 | 1 | false | false | false | false | true | true | true | $x = bool : 1 ( = true ) |
$x = int : 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | false | false | true | false | true | true | true | $x = int : 1 |
$x = int : 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | true | false | true | false | true | true | true | $x = int : 0 |
$x = int : -1 |
-1 | -1 | -1 | -1 | -1 | -1 | -1 | false | false | true | false | false | true | true | $x = int : -1 |
$x = int : 42 |
42 | 42 | 42 | 42 | 42 | 42 | 42 | false | false | true | false | true | true | true | $x = int : 42 |
†i8$x = int : 13369593 |
13369593 | 13369593 | 13369593 | 13369593 | 13369593 | 13369593 | 13369593 | false | false | true | true | true | true | true | †i8$x = int : 13369593 |
†i9$x = int : 42 |
42 | 42 | 42 | 42 | 42 | 42 | 42 | false | false | true | false | true | true | true | †i9$x = int : 42 |
$x = float : 1.3 |
1.3 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | false | true | true | false | true | true | true | $x = float : 1.3 |
$x = float : 0.005 |
0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | false | true | true | false | true | true | true | $x = float : 0.005 |
$x = float : 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | true | true | true | false | true | true | true | $x = float : 0 |
$x = float : -1.3 |
-1.3 | -1.3 | -1.3 | -1.3 | -1.3 | -1.3 | -1.3 | false | true | true | false | false | true | true | $x = float : -1.3 |
†f5$x = float : NAN |
NAN | NAN | NAN | NAN | b false |
null | NAN | true | true | true | false | false | false | false | †f5$x = float : NAN |
†f6$x = float : NAN |
NAN | NAN | NAN | NAN | b false |
null | NAN | true | true | true | false | false | false | false | †f6$x = float : NAN |
†f7$x = float : -INF |
-INF | -INF | -INF | -INF | b false |
null | -INF | false | true | true | false | false | false | false | †f7$x = float : -INF |
†f8$x = float : INF |
INF | INF | INF | INF | b false |
null | INF | false | true | true | false | false | false | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
123450000 | 123450000 | 123450000 | 123450000 | 123450000 | 123450000 | 123450000 | false | true | true | false | true | true | true | †f9$x = float : 123450000 |
†fa$x = string[3] : ‘⅕’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | true | †fa$x = string[3] : ‘⅕’ |
$x = string[0] : ‘’ |
0 | 0 | 0 | 0 | b false |
null | null | true | false | false | false | false | false | false | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | false | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
1 | 1 | 1 | 1 | 1 | 1 | 1 | false | false | true | false | false | false | false | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
3 | 3 | 3 | 3 | 3 | 3 | 3 | false | false | false | false | false | false | false | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
1 | 1 | 1 | 1 | 1 | 1 | 1 | false | false | true | true | true | true | true | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
0 | 0 | 0 | 0 | 0 | 0 | 0 | true | false | true | true | true | true | true | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
-1 | -1 | -1 | -1 | -1 | -1 | -1 | false | false | true | false | false | true | true | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
42 | 42 | 42 | 42 | 42 | 42 | 42 | false | false | true | true | true | true | true | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
1.3 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | false | false | true | false | true | true | true | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | true | false | true | true | true | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
-1.305 | -1.305 | -1.305 | -1.305 | -1.305 | -1.305 | -1.305 | false | false | true | false | false | true | true | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | false | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | false | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | false | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
123 | 123 | 123 | 123 | b false |
null | null | false | false | false | false | false | false | false | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
0 | 0 | 0 | 0 | b false |
null | null | false | false | false | false | false | false | false | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
123 | 123 | 123 | 123 | b false |
null | null | false | false | false | false | false | false | false | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
0 | 0 | 0 | 13369593 | b false |
null | null | false | false | true | false | false | false | false | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
123 | 123 | 123 | 123 | 123 | 123 | 123 | false | false | true | true | true | true | true | $x = string[4] : ‘0123’ |
$x = array() |
0 | 0 | 0 | Fatal error ( #2 ) |
array() |
array() |
null | true | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
1 | 1 | 1 | Fatal error ( #2 ) |
Array: ( [1] => b false ) |
Array: ( [1] => null ) |
Array: ( [1] => null ) |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
1 | 1 | 1 | Fatal error ( #2 ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => b false [4] => b false [5] => b false ) |
Array: ( [0] => null [1] => 1 [2] => 1.3 [3] => null [4] => null [5] => null ) |
Array: ( [0] => null [1] => 1 [2] => 1.3 [3] => null [4] => null [5] => null ) |
false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
1
( #5 ) |
b false |
b false |
null | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
1
( #4 ) |
1
( #4 ) |
1
( #4 ) |
1
( #5 ) |
b false |
null | null | false | false | false | false | false | false | false | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #59 ( = RESOURCE ) |
59 | 59 | 59 | 59 | b false |
null | null | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
$x = resource : Resource id #59 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Fatal error: Unsupported operand types
- Warning: preg_match() expects parameter 2 to be string, array/object/resource given
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to double
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to int
The code snippet is simplified for brevity. Please refer to the source of this file on GitHub for full details on how to use filter_var_array().
Uses an external library
Important: Integers between -128 and 255 are interpreted as the ASCII value pointing to a character (negative values have 256 added in order to allow characters in the Extended ASCII range).
In any other case, integers are interpreted as a string containing the decimal digits of the integer.
Numeric tests | is_numeric() | ctype_digit() ‡1 | preg_match (`^[\p{N}-]+$`u) | preg_match (`^[\p{N}\.-]+$`u) | > 0 | >= 0 | == 0 | === 0 | != 0 | !== 0 | < 0 | <= 0 | is_nan() | is_finite() | is_infinite() | floor() | ceil() | round() | Numeric tests |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Numeric tests | is_numeric() | ctype_digit() ‡1 | preg_match (`^[\p{N}-]+$`u) | preg_match (`^[\p{N}\.-]+$`u) | > 0 | >= 0 | == 0 | === 0 | != 0 | !== 0 | < 0 | <= 0 | is_nan() | is_finite() | is_infinite() | floor() | ceil() | round() | Numeric tests |
$x = null : ( = NULL ) |
false | false | false | false | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | false | false | false | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | false | false | false | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
false | false | true | true | true | true | false | false | true | true | false | false | false | true | false | 1 | 1 | 1 | $x = bool : 1 ( = true ) |
$x = int : 1 |
true | false | true | true | true | true | false | false | true | true | false | false | false | true | false | 1 | 1 | 1 | $x = int : 1 |
$x = int : 0 |
true | false | true | true | false | true | true | true | false | false | false | true | false | true | false | 0 | 0 | 0 | $x = int : 0 |
$x = int : -1 |
true | false | true | true | false | false | false | false | true | true | true | true | false | true | false | -1 | -1 | -1 | $x = int : -1 |
$x = int : 42 |
true | false | true | true | true | true | false | false | true | true | false | false | false | true | false | 42 | 42 | 42 | $x = int : 42 |
†i8$x = int : 13369593 |
true | true | true | true | true | true | false | false | true | true | false | false | false | true | false | 13369593 | 13369593 | 13369593 | †i8$x = int : 13369593 |
†i9$x = int : 42 |
true | false | true | true | true | true | false | false | true | true | false | false | false | true | false | 42 | 42 | 42 | †i9$x = int : 42 |
†ib$x = string[3] : ‘௫’ |
false | false | true | true | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | †ib$x = string[3] : ‘௫’ |
†ic$x = string[6] : ‘⁸₈’ |
false | false | true | true | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | †ic$x = string[6] : ‘⁸₈’ |
$x = float : 1.3 |
true | false | false | true | true | true | false | false | true | true | false | false | false | true | false | 1 | 2 | 1 | $x = float : 1.3 |
$x = float : 0.005 |
true | false | false | true | true | true | false | false | true | true | false | false | false | true | false | 0 | 1 | 0 | $x = float : 0.005 |
$x = float : 0 |
true | false | true | true | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = float : 0 |
$x = float : -1.3 |
true | false | false | true | false | false | false | false | true | true | true | true | false | true | false | -2 | -1 | -1 | $x = float : -1.3 |
†f5$x = float : NAN |
true | false | false | false | false | true | true | false | false | true | false | true | true | false | false | NAN | NAN | NAN | †f5$x = float : NAN |
†f6$x = float : NAN |
true | false | false | false | false | true | true | false | false | true | false | true | true | false | false | NAN | NAN | NAN | †f6$x = float : NAN |
†f7$x = float : -INF |
true | false | false | false | false | false | false | false | true | true | true | true | false | false | true | -INF | -INF | -INF | †f7$x = float : -INF |
†f8$x = float : INF |
true | false | false | false | true | true | false | false | true | true | false | false | false | false | true | INF | INF | INF | †f8$x = float : INF |
†f9$x = float : 123450000 |
true | false | true | true | true | true | false | false | true | true | false | false | false | true | false | 123450000 | 123450000 | 123450000 | †f9$x = float : 123450000 |
†fa$x = string[3] : ‘⅕’ |
false | false | true | true | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | †fa$x = string[3] : ‘⅕’ |
$x = string[0] : ‘’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
true | false | false | false | true | true | false | false | true | true | false | false | false | true | false | 1 | 1 | 1 | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
false | false | false | false | true | true | false | false | true | true | false | false | false
( #5 ) |
true
( #5 ) |
false
( #5 ) |
3 | 3 | 3 | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
true | true | true | true | true | true | false | false | true | true | false | false | false | true | false | 1 | 1 | 1 | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
true | true | true | true | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
true | false | true | true | false | false | false | false | true | true | true | true | false | true | false | -1 | -1 | -1 | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
true | true | true | true | true | true | false | false | true | true | false | false | false | true | false | 42 | 42 | 42 | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
true | false | false | true | true | true | false | false | true | true | false | false | false | true | false | 1 | 2 | 1 | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
true | false | false | true | false | true | true | false | false | true | false | true | false | true | false | 0 | 0 | 0 | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
true | false | false | true | false | false | false | false | true | true | true | true | false | true | false | -2 | -1 | -1 | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
false | false | false | false | true | true | false | false | true | true | false | false | false
( #5 ) |
true
( #5 ) |
false
( #5 ) |
123 | 123 | 123 | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
false | false | false | false | false | true | true | false | false | true | false | true | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
0 | 0 | 0 | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
false | false | false | false | true | true | false | false | true | true | false | false | false
( #5 ) |
true
( #5 ) |
false
( #5 ) |
123 | 123 | 123 | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
true | false | false | false | true | true | false | false | true | true | false | false | false | true | false | 13369593 | 13369593 | 13369593 | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
true | true | true | true | true | true | false | false | true | true | false | false | false | true | false | 123 | 123 | 123 | $x = string[4] : ‘0123’ |
$x = array() |
false | false | Error ( #6 ) |
Error ( #6 ) |
true | true | false | false | true | true | false | false | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
b false |
b false |
b false |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
false | false | Error ( #6 ) |
Error ( #6 ) |
true | true | false | false | true | true | false | false | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
b false |
b false |
b false |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
false | false | Error ( #6 ) |
Error ( #6 ) |
true | true | false | false | true | true | false | false | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
b false |
b false |
b false |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
false | false | Error ( #6 ) |
Error ( #6 ) |
true
( #7 ) |
true
( #7 ) |
false
( #7 ) |
false | true
( #7 ) |
true | false
( #7 ) |
false
( #7 ) |
null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
1
( #7 ) |
1
( #7 ) |
1
( #7 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
false | false | false | false | true
( #7 ) |
true
( #7 ) |
false
( #7 ) |
false | true
( #7 ) |
true | false
( #7 ) |
false
( #7 ) |
null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
1
( #7 ) |
1
( #7 ) |
1
( #7 ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #62 ( = RESOURCE ) |
false | false | Error ( #6 ) |
Error ( #6 ) |
true | true | false | false | true | true | false | false | null
( #2 ) |
null
( #3 ) |
null
( #4 ) |
62 | 62 | 62 | $x = resource : Resource id #62 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Warning: is_nan() expects parameter 1 to be double, string/array/object/resource given
- Warning: is_finite() expects parameter 1 to be double, string/array/object/resource given
- Warning: is_infinite() expects parameter 1 to be double, string/array/object/resource given
- Notice: A non well formed numeric value encountered
- Warning: preg_match() expects parameter 2 to be string, array/object/resource given
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to int
Important: Integers between -128 and 255 are interpreted as the ASCII value pointing to a character (negative values have 256 added in order to allow characters in the Extended ASCII range).
In any other case, integers are interpreted as a string containing the decimal digits of the integer.
String casting | settype ( $copy, 'string' ) ‡1 ‡2 | (string) | strval() | $x . '' | filter_var (…) | filter_var (…) ‡3 | CastToType::_string ( $x, false, false ) ‡4 | String casting |
---|---|---|---|---|---|---|---|---|
String casting | settype ( $copy, 'string' ) ‡1 ‡2 | (string) | strval() | $x . '' | filter_var (…) | filter_var (…) ‡3 | CastToType::_string ( $x, false, false ) ‡4 | String casting |
$x = null : ( = NULL ) |
‘’ | ‘’ | ‘’ | ‘ ’ | ‘’ | ‘’ | null | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
‘’ | ‘’ | ‘’ | ‘ ’ | ‘’ | ‘’ | null | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
‘’ | ‘’ | ‘’ | ‘ ’ | ‘’ | ‘’ | null | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
‘1’ | ‘1’ | ‘1’ | ‘1 ’ | ‘1’ | ‘1’ | null | $x = bool : 1 ( = true ) |
$x = int : 1 |
‘1’ | ‘1’ | ‘1’ | ‘1 ’ | ‘1’ | ‘1’ | ‘1’ | $x = int : 1 |
$x = int : 0 |
‘0’ | ‘0’ | ‘0’ | ‘0 ’ | ‘0’ | ‘0’ | ‘0’ | $x = int : 0 |
$x = int : -1 |
‘-1’ | ‘-1’ | ‘-1’ | ‘-1 ’ | ‘-1’ | ‘-1’ | ‘-1’ | $x = int : -1 |
$x = int : 42 |
‘42’ | ‘42’ | ‘42’ | ‘42 ’ | ‘42’ | ‘42’ | ‘42’ | $x = int : 42 |
†i8$x = int : 13369593 |
‘13369593’ | ‘13369593’ | ‘13369593’ | ‘13369593 ’ | ‘13369593’ | ‘13369593’ | ‘13369593’ | †i8$x = int : 13369593 |
†i9$x = int : 42 |
‘42’ | ‘42’ | ‘42’ | ‘42 ’ | ‘42’ | ‘42’ | ‘42’ | †i9$x = int : 42 |
$x = float : 1.3 |
‘1.3’ | ‘1.3’ | ‘1.3’ | ‘1.3 ’ | ‘1.3’ | ‘1.3’ | ‘1.3’ | $x = float : 1.3 |
$x = float : 0.005 |
‘0.005’ | ‘0.005’ | ‘0.005’ | ‘0.005 ’ | ‘0.005’ | ‘0.005’ | ‘0.005’ | $x = float : 0.005 |
$x = float : 0 |
‘0’ | ‘0’ | ‘0’ | ‘0 ’ | ‘0’ | ‘0’ | ‘0’ | $x = float : 0 |
$x = float : -1.3 |
‘-1.3’ | ‘-1.3’ | ‘-1.3’ | ‘-1.3 ’ | ‘-1.3’ | ‘-1.3’ | ‘-1.3’ | $x = float : -1.3 |
†f5$x = float : NAN |
‘NAN’ | ‘NAN’ | ‘NAN’ | ‘NAN ’ | ‘NAN’ | ‘NAN’ | ‘NAN’ | †f5$x = float : NAN |
†f6$x = float : NAN |
‘NAN’ | ‘NAN’ | ‘NAN’ | ‘NAN ’ | ‘NAN’ | ‘NAN’ | ‘NAN’ | †f6$x = float : NAN |
†f7$x = float : -INF |
‘-INF’ | ‘-INF’ | ‘-INF’ | ‘-INF ’ | ‘-INF’ | ‘-INF’ | ‘-INF’ | †f7$x = float : -INF |
†f8$x = float : INF |
‘INF’ | ‘INF’ | ‘INF’ | ‘INF ’ | ‘INF’ | ‘INF’ | ‘INF’ | †f8$x = float : INF |
†f9$x = float : 123450000 |
‘123450000’ | ‘123450000’ | ‘123450000’ | ‘123450000 ’ | ‘123450000’ | ‘123450000’ | ‘123450000’ | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
‘’ | ‘’ | ‘’ | ‘ ’ | ‘’ | ‘’ | null | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
‘ ’ | ‘ ’ | ‘ ’ | ‘ ’ | ‘ ’ | ‘ ’ | ‘ ’ | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
‘ 1’ | ‘ 1’ | ‘ 1’ | ‘ 1 ’ | ‘ 1’ | ‘ 1’ | ‘ 1’ | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
‘ 3 ’ | ‘ 3 ’ | ‘ 3 ’ | ‘ 3 ’ | ‘ 3 ’ | ‘ 3 ’ | ‘ 3 ’ | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
‘1’ | ‘1’ | ‘1’ | ‘1 ’ | ‘1’ | ‘1’ | ‘1’ | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
‘0’ | ‘0’ | ‘0’ | ‘0 ’ | ‘0’ | ‘0’ | ‘0’ | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
‘-1’ | ‘-1’ | ‘-1’ | ‘-1 ’ | ‘-1’ | ‘-1’ | ‘-1’ | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
‘42’ | ‘42’ | ‘42’ | ‘42 ’ | ‘42’ | ‘42’ | ‘42’ | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
‘1.3’ | ‘1.3’ | ‘1.3’ | ‘1.3 ’ | ‘1.3’ | ‘1.3’ | ‘1.3’ | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
‘0.0’ | ‘0.0’ | ‘0.0’ | ‘0.0 ’ | ‘0.0’ | ‘0.0’ | ‘0.0’ | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
‘-1.305’ | ‘-1.305’ | ‘-1.305’ | ‘-1.305 ’ | ‘-1.305’ | ‘-1.305’ | ‘-1.305’ | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
‘true’ | ‘true’ | ‘true’ | ‘true ’ | ‘true’ | ‘true’ | ‘true’ | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
‘false’ | ‘false’ | ‘false’ | ‘false ’ | ‘false’ | ‘false’ | ‘false’ | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
‘null’ | ‘null’ | ‘null’ | ‘null ’ | ‘null’ | ‘null’ | ‘null’ | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
‘123str’ | ‘123str’ | ‘123str’ | ‘123str ’ | ‘123str’ | ‘123str’ | ‘123str’ | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
‘str123’ | ‘str123’ | ‘str123’ | ‘str123 ’ | ‘str123’ | ‘str123’ | ‘str123’ | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
‘123, "str"’ | ‘123, "str"’ | ‘123, "str"’ | ‘123, "str" ’ | ‘123, "str"’ | ‘123, "str"’ | ‘123, "str"’ | $x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
‘0xCC00F9’ | ‘0xCC00F9’ | ‘0xCC00F9’ | ‘0xCC00F9 ’ | ‘0xCC00F9’ | ‘0xCC00F9’ | ‘0xCC00F9’ | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
‘0123’ | ‘0123’ | ‘0123’ | ‘0123 ’ | ‘0123’ | ‘0123’ | ‘0123’ | $x = string[4] : ‘0123’ |
$x = array() |
‘Array’
( #2 ) |
‘Array’ | ‘Array’ | ‘Array ’ | array() |
array() |
null | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
‘Array’
( #2 ) |
‘Array’ | ‘Array’ | ‘Array ’ | Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
‘Array’
( #2 ) |
‘Array’ | ‘Array’ | ‘Array ’ | Array: ( [0] => ‘’ [1] => ‘1’ [2] => ‘1.3’ [3] => ‘123str’ [4] => ‘str123’ [5] => ‘’ ) |
Array: ( [0] => ‘’ [1] => ‘1’ [2] => ‘1.3’ [3] => ‘123str’ [4] => ‘str123’ [5] => ‘’ ) |
Array: ( [0] => null [1] => ‘1’ [2] => ‘1.3’ [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
‘Object’
(Catchable) Fatal error ( #3 ) ( #4 ) |
‘’
(Catchable) Fatal error ( #3 ) |
‘’
(Catchable) Fatal error ( #3 ) |
‘ ’
(Catchable) Fatal error ( #3 ) |
b false |
b false |
null | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
‘some string’ | ‘some string’ | ‘some string’ | ‘some string ’ | ‘some string’ | ‘some string’ | ‘some string’ | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #65 ( = RESOURCE ) |
‘Resource id #65’ | ‘Resource id #65’ | ‘Resource id #65’ | ‘Resource id #65 ’ | ‘Resource id #65’ | ‘Resource id #65’ | null | $x = resource : Resource id #65 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Notice: Array to string conversion
- (Catchable) Fatal error: Object of class stdClass/TestObject/TestObjectToString could not be converted to string
- Notice: Object of class stdClass/TestObject/TestObjectToString to string conversion
Depending on your error handling settings/exception catching and your PHP version, using settype( $copy, 'string' )
on an object which does not have a __toString()
method will result either in the string Object
or will return a (catchable) fatal error.
Before PHP < 5.2.0, the __toString()
method was only available to echo/print statements, so casting to string would still result in Object
, even when the object contained a __toString()
method.
The code snippet is simplified for brevity. Please refer to the source of this file on GitHub for full details on how to use filter_var_array().
Uses an external library
String tests | is_string() | empty() | == '' | === '' | ctype_alpha() ‡1 | preg_match (`^[A-Za-z]+$`) | preg_match (`^\p{L}+$`u) | ctype_alnum() ‡1 | preg_match (`^[A-Za-z0-9]+$`) | preg_match (`^\w+$`) | preg_match (`^\w+$`u) ‡2 | preg_match (`^[\p{L}\p{N}]+$`u) | strlen() | count_chars (…) | mb_strlen() | $x{2} | trim() | String tests |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
String tests | is_string() | empty() | == '' | === '' | ctype_alpha() ‡1 | preg_match (`^[A-Za-z]+$`) | preg_match (`^\p{L}+$`u) | ctype_alnum() ‡1 | preg_match (`^[A-Za-z0-9]+$`) | preg_match (`^\w+$`) | preg_match (`^\w+$`u) ‡2 | preg_match (`^[\p{L}\p{N}]+$`u) | strlen() | count_chars (…) | mb_strlen() | $x{2} | trim() | String tests |
$x = null : ( = NULL ) |
false | true | true | false | false | false | false | false | false | false | false | false | 0 | 0 |
0 | null | ‘’ |
$x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | true | true | false | false | false | false | false | false | false | false | false | 0 | 0 |
0 | null | ‘’ |
$x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | true | true | false | false | false | false | false | false | false | false | false | 0 | 0 |
0 | null | ‘’ |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
false | false | false | false | false | false | false | false | true | true | true | true | 1 | 1 |
1 | null | ‘1’ |
$x = bool : 1 ( = true ) |
$x = int : 1 |
false | false | false | false | false | false | false | false | true | true | true | true | 1 | 1 |
1 | null | ‘1’ |
$x = int : 1 |
$x = int : 0 |
false | true | true | false | false | false | false | false | true | true | true | true | 1 | 1 |
1 | null | ‘0’ |
$x = int : 0 |
$x = int : -1 |
false | false | false | false | false | false | false | false | false | false | false | false | 2 | 2 |
2 | null | ‘-1’ |
$x = int : -1 |
$x = int : 42 |
false | false | false | false | false | false | false | false | true | true | true | true | 2 | 2 |
2 | null | ‘42’ |
$x = int : 42 |
†i8$x = int : 13369593 |
false | false | false | false | false | false | false | true | true | true | true | true | 8 | 8 |
8 | null | ‘13369593’ |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
false | false | false | false | false | false | false | false | true | true | true | true | 2 | 2 |
2 | null | ‘42’ |
†i9$x = int : 42 |
$x = float : 1.3 |
false | false | false | false | false | false | false | false | false | false | false | false | 3 | 3 |
3 | null | ‘1.3’ |
$x = float : 1.3 |
$x = float : 0.005 |
false | false | false | false | false | false | false | false | false | false | false | false | 5 | 5 |
5 | null | ‘0.005’ |
$x = float : 0.005 |
$x = float : 0 |
false | true | true | false | false | false | false | false | true | true | true | true | 1 | 1 |
1 | null | ‘0’ |
$x = float : 0 |
$x = float : -1.3 |
false | false | false | false | false | false | false | false | false | false | false | false | 4 | 4 |
4 | null | ‘-1.3’ |
$x = float : -1.3 |
†f5$x = float : NAN |
false | true | true | false | false | true | true | false | true | true | true | true | 3 | 3 |
3 | null | ‘NAN’ |
†f5$x = float : NAN |
†f6$x = float : NAN |
false | true | true | false | false | true | true | false | true | true | true | true | 3 | 3 |
3 | null | ‘NAN’ |
†f6$x = float : NAN |
†f7$x = float : -INF |
false | false | false | false | false | false | false | false | false | false | false | false | 4 | 4 |
4 | null | ‘-INF’ |
†f7$x = float : -INF |
†f8$x = float : INF |
false | false | false | false | false | true | true | false | true | true | true | true | 3 | 3 |
3 | null | ‘INF’ |
†f8$x = float : INF |
†f9$x = float : 123450000 |
false | false | false | false | false | false | false | false | true | true | true | true | 9 | 9 |
9 | null | ‘123450000’ |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
true | true | true | true | false | false | false | false | false | false | false | false | 0 | 0 |
0 | ‘’ ( #2 ) |
‘’ |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
true | false | false | false | false | false | false | false | false | false | false | false | 1 | 1 |
1 | ‘’ ( #2 ) |
‘’ |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
true | false | false | false | false | false | false | false | false | false | false | false | 2 | 2 |
2 | ‘’ ( #2 ) |
‘1’ |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
true | false | false | false | false | false | false | false | false | false | false | false | 3 | 3 |
3 | ‘ ’ |
‘3’ |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
true | false | false | false | false | false | false | true | true | true | true | true | 1 | 1 |
1 | ‘’ ( #2 ) |
‘1’ |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
true | true | false | false | false | false | false | true | true | true | true | true | 1 | 1 |
1 | ‘’ ( #2 ) |
‘0’ |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
true | false | false | false | false | false | false | false | false | false | false | false | 2 | 2 |
2 | ‘’ ( #2 ) |
‘-1’ |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
true | false | false | false | false | false | false | true | true | true | true | true | 2 | 2 |
2 | ‘’ ( #2 ) |
‘42’ |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
true | false | false | false | false | false | false | false | false | false | false | false | 3 | 3 |
3 | ‘3’ |
‘1.3’ |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
true | false | false | false | false | false | false | false | false | false | false | false | 3 | 3 |
3 | ‘0’ |
‘0.0’ |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
true | false | false | false | false | false | false | false | false | false | false | false | 6 | 6 |
6 | ‘.’ |
‘-1.305’ |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
true | false | false | false | true | true | true | true | true | true | true | true | 4 | 4 |
4 | ‘u’ |
‘true’ |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
true | false | false | false | true | true | true | true | true | true | true | true | 5 | 5 |
5 | ‘l’ |
‘false’ |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
true | false | false | false | true | true | true | true | true | true | true | true | 4 | 4 |
4 | ‘l’ |
‘null’ |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
true | false | false | false | false | false | false | true | true | true | true | true | 6 | 6 |
6 | ‘3’ |
‘123str’ |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
true | false | false | false | false | false | false | true | true | true | true | true | 6 | 6 |
6 | ‘r’ |
‘str123’ |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
true | false | false | false | false | false | false | false | false | false | false | false | 10 | 10 |
10 | ‘3’ |
‘123, "str"’ |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
true | false | false | false | false | false | false | true | true | true | true | true | 8 | 8 |
8 | ‘C’ |
‘0xCC00F9’ |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
true | false | false | false | false | false | false | true | true | true | true | true | 4 | 4 |
4 | ‘2’ |
‘0123’ |
$x = string[4] : ‘0123’ |
$x = string[27] : ‘Iñtërnâtiônàlizætiøn’ |
true | false | false | false | false | false | true | false | false | false | false | true | 27 | 27 |
20 | ‘’ |
‘Iñtërnâtiônàlizætiøn’ |
$x = string[27] : ‘Iñtërnâtiônàlizætiøn’ |
$x = array() |
false | true | false | false | false | Error ( #3 ) |
Error ( #3 ) |
false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
5
( #4 ) |
5 ( #4 ) |
false
( #5 ) |
null
( #6 ) |
‘Array’ ( #4 ) |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
false | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
5
( #4 ) |
5 ( #4 ) |
false
( #5 ) |
null
( #6 ) |
‘Array’ ( #4 ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
false | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
5
( #4 ) |
5 ( #4 ) |
false
( #5 ) |
1.3 |
‘Array’ ( #4 ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
false | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
6
(Catchable) Fatal error ( #7 ) ( #8 ) |
6 (Catchable) Fatal error ( #7 ) ( #8 ) |
false
( #5 ) |
Fatal error ( #9 ) |
‘Object’ (Catchable) Fatal error ( #7 ) ( #8 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
false | false | false | false | false | false | false | false | false | false | false | false | 11 | 11 |
11 | Fatal error ( #9 ) |
‘some string’ |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #68 ( = RESOURCE ) |
false | false | false | false | false | Error ( #3 ) |
Error ( #3 ) |
false | Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
Error ( #3 ) |
15 | 15 |
false
( #5 ) |
null | ‘Resource id #68’ |
$x = resource : Resource id #68 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Notice: Uninitialized string offset: 2
- Warning: preg_match() expects parameter 2 to be string, array/object/resource given
- Notice: Array to string conversion
- Warning: mb_strlen() expects parameter 1 to be string, array/object/resource given
- Notice: Undefined offset: 2
- (Catchable) Fatal error: Object of class stdClass/TestObject/TestObjectToString could not be converted to string
- Notice: Object of class stdClass/TestObject/TestObjectToString to string conversion
- Fatal error: Cannot use object of type stdClass/TestObject/TestObjectToString as array
Important: Integers between -128 and 255 are interpreted as the ASCII value pointing to a character (negative values have 256 added in order to allow characters in the Extended ASCII range).
In any other case, integers are interpreted as a string containing the decimal digits of the integer.
What \w
matches is locale dependent. The locale for these cheatsheets are set to C
. Results with other locales will vary.
Array casting | settype ( $copy, 'array' ) | (array) | CastToType::_array ( $x, false ) ‡1 | Array casting |
---|---|---|---|---|
Array casting | settype ( $copy, 'array' ) | (array) | CastToType::_array ( $x, false ) ‡1 | Array casting |
$x = null : ( = NULL ) |
array() |
array() |
null | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
array() |
array() |
null | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
Array: ( [0] => b false ) |
Array: ( [0] => b false ) |
Array: ( [0] => b false ) |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
Array: ( [0] => b true ) |
Array: ( [0] => b true ) |
Array: ( [0] => b true ) |
$x = bool : 1 ( = true ) |
$x = int : 1 |
Array: ( [0] => 1 ) |
Array: ( [0] => 1 ) |
Array: ( [0] => 1 ) |
$x = int : 1 |
$x = int : 0 |
Array: ( [0] => 0 ) |
Array: ( [0] => 0 ) |
Array: ( [0] => 0 ) |
$x = int : 0 |
$x = int : -1 |
Array: ( [0] => -1 ) |
Array: ( [0] => -1 ) |
Array: ( [0] => -1 ) |
$x = int : -1 |
$x = int : 42 |
Array: ( [0] => 42 ) |
Array: ( [0] => 42 ) |
Array: ( [0] => 42 ) |
$x = int : 42 |
†i8$x = int : 13369593 |
Array: ( [0] => 13369593 ) |
Array: ( [0] => 13369593 ) |
Array: ( [0] => 13369593 ) |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
Array: ( [0] => 42 ) |
Array: ( [0] => 42 ) |
Array: ( [0] => 42 ) |
†i9$x = int : 42 |
$x = float : 1.3 |
Array: ( [0] => 1.3 ) |
Array: ( [0] => 1.3 ) |
Array: ( [0] => 1.3 ) |
$x = float : 1.3 |
$x = float : 0.005 |
Array: ( [0] => 0.005 ) |
Array: ( [0] => 0.005 ) |
Array: ( [0] => 0.005 ) |
$x = float : 0.005 |
$x = float : 0 |
Array: ( [0] => 0 ) |
Array: ( [0] => 0 ) |
Array: ( [0] => 0 ) |
$x = float : 0 |
$x = float : -1.3 |
Array: ( [0] => -1.3 ) |
Array: ( [0] => -1.3 ) |
Array: ( [0] => -1.3 ) |
$x = float : -1.3 |
†f5$x = float : NAN |
Array: ( [0] => NAN ) |
Array: ( [0] => NAN ) |
Array: ( [0] => NAN ) |
†f5$x = float : NAN |
†f6$x = float : NAN |
Array: ( [0] => NAN ) |
Array: ( [0] => NAN ) |
Array: ( [0] => NAN ) |
†f6$x = float : NAN |
†f7$x = float : -INF |
Array: ( [0] => -INF ) |
Array: ( [0] => -INF ) |
Array: ( [0] => -INF ) |
†f7$x = float : -INF |
†f8$x = float : INF |
Array: ( [0] => INF ) |
Array: ( [0] => INF ) |
Array: ( [0] => INF ) |
†f8$x = float : INF |
†f9$x = float : 123450000 |
Array: ( [0] => 123450000 ) |
Array: ( [0] => 123450000 ) |
Array: ( [0] => 123450000 ) |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
Array: ( [0] => ‘’ ) |
Array: ( [0] => ‘’ ) |
Array: ( [0] => ‘’ ) |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
Array: ( [0] => ‘ ’ ) |
Array: ( [0] => ‘ ’ ) |
Array: ( [0] => ‘ ’ ) |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
Array: ( [0] => ‘ 1’ ) |
Array: ( [0] => ‘ 1’ ) |
Array: ( [0] => ‘ 1’ ) |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
Array: ( [0] => ‘ 3 ’ ) |
Array: ( [0] => ‘ 3 ’ ) |
Array: ( [0] => ‘ 3 ’ ) |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
Array: ( [0] => ‘1’ ) |
Array: ( [0] => ‘1’ ) |
Array: ( [0] => ‘1’ ) |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
Array: ( [0] => ‘0’ ) |
Array: ( [0] => ‘0’ ) |
Array: ( [0] => ‘0’ ) |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
Array: ( [0] => ‘-1’ ) |
Array: ( [0] => ‘-1’ ) |
Array: ( [0] => ‘-1’ ) |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
Array: ( [0] => ‘42’ ) |
Array: ( [0] => ‘42’ ) |
Array: ( [0] => ‘42’ ) |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
Array: ( [0] => ‘1.3’ ) |
Array: ( [0] => ‘1.3’ ) |
Array: ( [0] => ‘1.3’ ) |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
Array: ( [0] => ‘0.0’ ) |
Array: ( [0] => ‘0.0’ ) |
Array: ( [0] => ‘0.0’ ) |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
Array: ( [0] => ‘-1.305’ ) |
Array: ( [0] => ‘-1.305’ ) |
Array: ( [0] => ‘-1.305’ ) |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
Array: ( [0] => ‘true’ ) |
Array: ( [0] => ‘true’ ) |
Array: ( [0] => ‘true’ ) |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
Array: ( [0] => ‘false’ ) |
Array: ( [0] => ‘false’ ) |
Array: ( [0] => ‘false’ ) |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
Array: ( [0] => ‘null’ ) |
Array: ( [0] => ‘null’ ) |
Array: ( [0] => ‘null’ ) |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
Array: ( [0] => ‘123str’ ) |
Array: ( [0] => ‘123str’ ) |
Array: ( [0] => ‘123str’ ) |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
Array: ( [0] => ‘str123’ ) |
Array: ( [0] => ‘str123’ ) |
Array: ( [0] => ‘str123’ ) |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
Array: ( [0] => ‘123, "str"’ ) |
Array: ( [0] => ‘123, "str"’ ) |
Array: ( [0] => ‘123, "str"’ ) |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
Array: ( [0] => ‘0xCC00F9’ ) |
Array: ( [0] => ‘0xCC00F9’ ) |
Array: ( [0] => ‘0xCC00F9’ ) |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
Array: ( [0] => ‘0123’ ) |
Array: ( [0] => ‘0123’ ) |
Array: ( [0] => ‘0123’ ) |
$x = string[4] : ‘0123’ |
$x = array() |
array() |
array() |
null | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
array() |
array() |
null | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
Array: ( [test3] => ‘some string’ [test1] => null [test2] => b true ) |
Array: ( [test3] => ‘some string’ [test1] => null [test2] => b true ) |
Array: ( [test3] => ‘some string’ [test1] => null [test2] => b true ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #71 ( = RESOURCE ) |
Array: ( [0] => Resource id #71 ) |
Array: ( [0] => Resource id #71 ) |
Array: ( [0] => Resource id #71 ) |
$x = resource : Resource id #71 ( = RESOURCE ) |
- Notice: Undefined index: notset
Uses an external library
Array testing | is_array() | count() | empty() | count() > 0 | is_iterable() | is_countable() | isset ( $x[0] ) ‡1 | array_key_exists ( 0, $x ) ‡1 | isset ( $x['foo'] ) ‡1 | key() | current() | $x['foo'] | $x['foo']['bar'] | array_filter() | Array testing |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Array testing | is_array() | count() | empty() | count() > 0 | is_iterable() | is_countable() | isset ( $x[0] ) ‡1 | array_key_exists ( 0, $x ) ‡1 | isset ( $x['foo'] ) ‡1 | key() | current() | $x['foo'] | $x['foo']['bar'] | array_filter() | Array testing |
$x = null : ( = NULL ) |
false | 0 | true | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | 0 | true | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = bool : 1 ( = true ) |
$x = int : 1 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = int : 1 |
$x = int : 0 |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = int : 0 |
$x = int : -1 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = int : -1 |
$x = int : 42 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = int : 42 |
†i8$x = int : 13369593 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†i9$x = int : 42 |
$x = float : 1.3 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = float : 1.3 |
$x = float : 0.005 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = float : 0.005 |
$x = float : 0 |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = float : 0 |
$x = float : -1.3 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = float : -1.3 |
†f5$x = float : NAN |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†f5$x = float : NAN |
†f6$x = float : NAN |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†f6$x = float : NAN |
†f7$x = float : -INF |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†f7$x = float : -INF |
†f8$x = float : INF |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†f8$x = float : INF |
†f9$x = float : 123450000 |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
‘’ ( #6 ) |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘ ’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘ ’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘ ’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘1’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
false | 1 | true | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘0’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘-’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘4’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘1’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘0’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘-’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘t’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘f’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘n’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘1’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘s’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘1’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘0’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | false
( #2 ) ( #2 ) |
true | b false ( #3 ) |
b false ( #4 ) |
‘0’ |
Fatal error ( #7 ) |
null
( #5 ) |
$x = string[4] : ‘0123’ |
$x = array() |
true | 0 | true | false | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false | false | null | b false |
null
( #8 ) |
null
( #8 ) |
array() |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
true | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false | false | 1 |
‘string’ |
null
( #8 ) |
null
( #8 ) |
Array: ( [1] => ‘string’ ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
true | 6 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | true | true | false | 0 |
b false |
null
( #8 ) |
null
( #8 ) |
Array: ( [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | Fatal error ( #9 ) |
false | Fatal error ( #9 ) |
null | b false |
Fatal error ( #9 ) |
Fatal error ( #9 ) |
null
( #5 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObject ( property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: print_it ) ) |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | Fatal error ( #9 ) |
false | Fatal error ( #9 ) |
‘test1’ |
null | Fatal error ( #9 ) |
Fatal error ( #9 ) |
null
( #5 ) |
$x = Object:
( Class: TestObject ( property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: print_it ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | Fatal error ( #9 ) |
false | Fatal error ( #9 ) |
‘test3’ |
‘some string’ |
Fatal error ( #9 ) |
Fatal error ( #9 ) |
null
( #5 ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #74 ( = RESOURCE ) |
false | 1 | false | true | E: not available (PHP 7.1.0+) | E: not available (PHP 7.3.0+) | false | false
( #2 ) ( #2 ) |
false | b false ( #3 ) |
b false ( #4 ) |
null | null | null
( #5 ) |
$x = resource : Resource id #74 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object
- Warning: key() [function.key]: Passed variable is not an array or object
- Warning: current() [function.current]: Passed variable is not an array or object
- Warning: array_filter() [function.array-filter]: The first argument should be an array
- Notice: Uninitialized string offset: 0
- Fatal error: Cannot use string offset as an array
- Notice: Undefined index: foo
- Fatal error: Cannot use object of type stdClass/TestObject/TestObjectToString as array
Whether to use isset()
or array_key_exists()
depends on what you want to know:
isset( $array[$key] )
will tell you whether the array key exists and has been assigned a value.
Used on its own it will give undesired results when used on strings as characters within a string can be approached using the$x[]
syntax as well.
Also, it will cause fatal errors when used on objects.array_key_exists( $key, $array )
will tell you only whether the array key exists, but will not check whether it has a value assigned to it.
Used on its own, it will show a warning if $array is not an array
This said, we can conclude that to avoid warnings and undesired results you will always have to use an is_array()
first.
Also note that isset()
is faster than array_key_exists()
, but as said above, will return false if no value has been assigned.
Objects | settype ( $copy, 'object' ) | (object) | CastToType::_object ( $x, false ) ‡1 | is_object() | is_a ( $x, 'TestObject' ) | instanceof TestObject | get_class() | get_parent_class() | is_subclass_of ( $x, 'TestObject' ) | Objects |
---|---|---|---|---|---|---|---|---|---|---|
Objects | settype ( $copy, 'object' ) | (object) | CastToType::_object ( $x, false ) ‡1 | is_object() | is_a ( $x, 'TestObject' ) | instanceof TestObject | get_class() | get_parent_class() | is_subclass_of ( $x, 'TestObject' ) | Objects |
$x = null : ( = NULL ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
null | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
null | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
Object:
( Class: stdClass ( property: scalar = b false ) ) |
Object:
( Class: stdClass ( property: scalar = b false ) ) |
Object:
( Class: stdClass ( property: scalar = b false ) ) |
false | false | false | false | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
Object:
( Class: stdClass ( property: scalar = b true ) ) |
Object:
( Class: stdClass ( property: scalar = b true ) ) |
Object:
( Class: stdClass ( property: scalar = b true ) ) |
false | false | false | false | false | false | $x = bool : 1 ( = true ) |
$x = int : 1 |
Object:
( Class: stdClass ( property: scalar = 1 ) ) |
Object:
( Class: stdClass ( property: scalar = 1 ) ) |
Object:
( Class: stdClass ( property: scalar = 1 ) ) |
false | false | false | false | false | false | $x = int : 1 |
$x = int : 0 |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
false | false | false | false | false | false | $x = int : 0 |
$x = int : -1 |
Object:
( Class: stdClass ( property: scalar = -1 ) ) |
Object:
( Class: stdClass ( property: scalar = -1 ) ) |
Object:
( Class: stdClass ( property: scalar = -1 ) ) |
false | false | false | false | false | false | $x = int : -1 |
$x = int : 42 |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
false | false | false | false | false | false | $x = int : 42 |
†i8$x = int : 13369593 |
Object:
( Class: stdClass ( property: scalar = 13369593 ) ) |
Object:
( Class: stdClass ( property: scalar = 13369593 ) ) |
Object:
( Class: stdClass ( property: scalar = 13369593 ) ) |
false | false | false | false | false | false | †i8$x = int : 13369593 |
†i9$x = int : 42 |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
Object:
( Class: stdClass ( property: scalar = 42 ) ) |
false | false | false | false | false | false | †i9$x = int : 42 |
$x = float : 1.3 |
Object:
( Class: stdClass ( property: scalar = 1.3 ) ) |
Object:
( Class: stdClass ( property: scalar = 1.3 ) ) |
Object:
( Class: stdClass ( property: scalar = 1.3 ) ) |
false | false | false | false | false | false | $x = float : 1.3 |
$x = float : 0.005 |
Object:
( Class: stdClass ( property: scalar = 0.005 ) ) |
Object:
( Class: stdClass ( property: scalar = 0.005 ) ) |
Object:
( Class: stdClass ( property: scalar = 0.005 ) ) |
false | false | false | false | false | false | $x = float : 0.005 |
$x = float : 0 |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
Object:
( Class: stdClass ( property: scalar = 0 ) ) |
false | false | false | false | false | false | $x = float : 0 |
$x = float : -1.3 |
Object:
( Class: stdClass ( property: scalar = -1.3 ) ) |
Object:
( Class: stdClass ( property: scalar = -1.3 ) ) |
Object:
( Class: stdClass ( property: scalar = -1.3 ) ) |
false | false | false | false | false | false | $x = float : -1.3 |
†f5$x = float : NAN |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
false | false | false | false | false | false | †f5$x = float : NAN |
†f6$x = float : NAN |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
Object:
( Class: stdClass ( property: scalar = NAN ) ) |
false | false | false | false | false | false | †f6$x = float : NAN |
†f7$x = float : -INF |
Object:
( Class: stdClass ( property: scalar = -INF ) ) |
Object:
( Class: stdClass ( property: scalar = -INF ) ) |
Object:
( Class: stdClass ( property: scalar = -INF ) ) |
false | false | false | false | false | false | †f7$x = float : -INF |
†f8$x = float : INF |
Object:
( Class: stdClass ( property: scalar = INF ) ) |
Object:
( Class: stdClass ( property: scalar = INF ) ) |
Object:
( Class: stdClass ( property: scalar = INF ) ) |
false | false | false | false | false | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
Object:
( Class: stdClass ( property: scalar = 123450000 ) ) |
Object:
( Class: stdClass ( property: scalar = 123450000 ) ) |
Object:
( Class: stdClass ( property: scalar = 123450000 ) ) |
false | false | false | false | false | false | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
Object:
( Class: stdClass ( property: scalar = ‘’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘’ ) ) |
null | false | false | false | false | false | false
( #2 ) |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
Object:
( Class: stdClass ( property: scalar = ‘ ’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ ’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ ’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
Object:
( Class: stdClass ( property: scalar = ‘ 1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ 1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ 1’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
Object:
( Class: stdClass ( property: scalar = ‘ 3 ’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ 3 ’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘ 3 ’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
Object:
( Class: stdClass ( property: scalar = ‘1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘1’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
Object:
( Class: stdClass ( property: scalar = ‘0’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
Object:
( Class: stdClass ( property: scalar = ‘-1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘-1’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘-1’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
Object:
( Class: stdClass ( property: scalar = ‘42’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘42’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘42’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
Object:
( Class: stdClass ( property: scalar = ‘1.3’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘1.3’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘1.3’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
Object:
( Class: stdClass ( property: scalar = ‘0.0’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0.0’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0.0’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
Object:
( Class: stdClass ( property: scalar = ‘-1.305’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘-1.305’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘-1.305’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
Object:
( Class: stdClass ( property: scalar = ‘true’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘true’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘true’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
Object:
( Class: stdClass ( property: scalar = ‘false’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘false’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘false’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
Object:
( Class: stdClass ( property: scalar = ‘null’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘null’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘null’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
Object:
( Class: stdClass ( property: scalar = ‘123str’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘123str’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘123str’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
Object:
( Class: stdClass ( property: scalar = ‘str123’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘str123’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘str123’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
Object:
( Class: stdClass ( property: scalar = ‘123, "str"’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘123, "str"’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘123, "str"’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
Object:
( Class: stdClass ( property: scalar = ‘0xCC00F9’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0xCC00F9’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0xCC00F9’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
Object:
( Class: stdClass ( property: scalar = ‘0123’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0123’ ) ) |
Object:
( Class: stdClass ( property: scalar = ‘0123’ ) ) |
false | false | false | false | false | false
( #2 ) |
$x = string[4] : ‘0123’ |
$x = array() |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
null | false | false | false | false | false | false | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( property: 1 = ‘string’ ) ) |
false | false | false | false | false | false | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( property: 0 = b false property: 1 = 1 property: 2 = 1.3 property: 3 = ‘123str’ property: 4 = ‘str123’ property: 5 = null ) ) |
false | false | false | false | false | false | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Array: ( [s (string)] => string[6] : ‘simple’ [m (string)] => Array: ( [0 (int)] => string[5] : ‘test1’ [1 (int)] => string[5] : ‘test2’ ) ) |
Object:
( Class: stdClass ( property: s = ‘simple’ property: m (array) Array: ( [0] => ‘test1’ [1] => ‘test2’ ) ) ) |
Object:
( Class: stdClass ( property: s = ‘simple’ property: m (array) Array: ( [0] => ‘test1’ [1] => ‘test2’ ) ) ) |
Object:
( Class: stdClass ( property: s = ‘simple’ property: m (array) Array: ( [0] => ‘test1’ [1] => ‘test2’ ) ) ) |
false | false | false | false | false | false | $x = Array: ( [s (string)] => string[6] : ‘simple’ [m (string)] => Array: ( [0 (int)] => string[5] : ‘test1’ [1 (int)] => string[5] : ‘test2’ ) ) |
$x = Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
null | true | false | false | ‘stdClass’ |
false | false | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObject ( property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: print_it ) ) |
Object:
( Class: TestObject ( property: test1 = null property: test2 = b true method: print_it ) ) |
Object:
( Class: TestObject ( property: test1 = null property: test2 = b true method: print_it ) ) |
Object:
( Class: TestObject ( property: test1 = null property: test2 = b true method: print_it ) ) |
true | true | true | ‘TestObject’ |
false | false | $x = Object:
( Class: TestObject ( property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: print_it ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
true | true | true | ‘TestObjectToString’ |
‘TestObject’ |
true | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #77 ( = RESOURCE ) |
Object:
( Class: stdClass ( property: scalar = Resource id #77 ) ) |
Object:
( Class: stdClass ( property: scalar = Resource id #77 ) ) |
Object:
( Class: stdClass ( property: scalar = Resource id #77 ) ) |
false | false | false | false | false | false | $x = resource : Resource id #77 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Warning: Unknown class passed as parameter
Uses an external library
Resources | is_resource() | get_resource_type() | Resources |
---|---|---|---|
Resources | is_resource() | get_resource_type() | Resources |
$x = null : ( = NULL ) |
false | false
( #2 ) |
$x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | false
( #2 ) |
$x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | false
( #2 ) |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
false | false
( #2 ) |
$x = bool : 1 ( = true ) |
$x = int : 1 |
false | false
( #2 ) |
$x = int : 1 |
$x = int : 0 |
false | false
( #2 ) |
$x = int : 0 |
$x = int : -1 |
false | false
( #2 ) |
$x = int : -1 |
$x = int : 42 |
false | false
( #2 ) |
$x = int : 42 |
†i8$x = int : 13369593 |
false | false
( #2 ) |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
false | false
( #2 ) |
†i9$x = int : 42 |
$x = float : 1.3 |
false | false
( #2 ) |
$x = float : 1.3 |
$x = float : 0.005 |
false | false
( #2 ) |
$x = float : 0.005 |
$x = float : 0 |
false | false
( #2 ) |
$x = float : 0 |
$x = float : -1.3 |
false | false
( #2 ) |
$x = float : -1.3 |
†f5$x = float : NAN |
false | false
( #2 ) |
†f5$x = float : NAN |
†f6$x = float : NAN |
false | false
( #2 ) |
†f6$x = float : NAN |
†f7$x = float : -INF |
false | false
( #2 ) |
†f7$x = float : -INF |
†f8$x = float : INF |
false | false
( #2 ) |
†f8$x = float : INF |
†f9$x = float : 123450000 |
false | false
( #2 ) |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
false | false
( #2 ) |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
false | false
( #2 ) |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
false | false
( #2 ) |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
false | false
( #2 ) |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
false | false
( #2 ) |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
false | false
( #2 ) |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
false | false
( #2 ) |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
false | false
( #2 ) |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
false | false
( #2 ) |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
false | false
( #2 ) |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
false | false
( #2 ) |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
false | false
( #2 ) |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
false | false
( #2 ) |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
false | false
( #2 ) |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
false | false
( #2 ) |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
false | false
( #2 ) |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
false | false
( #2 ) |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
false | false
( #2 ) |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
false | false
( #2 ) |
$x = string[4] : ‘0123’ |
$x = array() |
false | false
( #2 ) |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
false | false
( #2 ) |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
false | false
( #2 ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
false | false
( #2 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
false | false
( #2 ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #80 ( = RESOURCE ) |
true | ‘stream’ | $x = resource : Resource id #80 ( = RESOURCE ) |
$x = resource : Resource id #81 ( = RESOURCE ) |
true | ‘gd’ | $x = resource : Resource id #81 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Warning: Supplied argument is not a valid resource handle
Basic Arithmetic | $x = ++$x ‡1 | $x = $x++ ‡1 | $x = --$x ‡1 | $x = $x-- ‡1 | -$x | $x + 0 | $x - 0 | $x * 1 | $x / 1 | $x % 1 | Basic Arithmetic |
---|---|---|---|---|---|---|---|---|---|---|---|
Basic Arithmetic | $x = ++$x ‡1 | $x = $x++ ‡1 | $x = --$x ‡1 | $x = $x-- ‡1 | -$x | $x + 0 | $x - 0 | $x * 1 | $x / 1 | $x % 1 | Basic Arithmetic |
$x = null : ( = NULL ) |
1 | null | null | null | 0 |
0 | 0 |
0 |
0 |
0 |
$x = null : ( = NULL ) |
$x = null : ( = NULL ) |
1 | null | null | null | 0 |
0 | 0 |
0 |
0 |
0 |
$x = null : ( = NULL ) |
$x = bool : ( = false ) |
b false |
b false |
b false |
b false |
0 |
0 | 0 |
0 |
0 |
0 |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
b true |
b true |
b true |
b true |
-1 |
1 | 1 |
1 |
1 |
0 |
$x = bool : 1 ( = true ) |
$x = int : 1 |
2 | 1 | 0 | 1 | -1 |
1 | 1 |
1 |
1 |
0 |
$x = int : 1 |
$x = int : 0 |
1 | 0 | -1 | 0 | 0 |
0 | 0 |
0 |
0 |
0 |
$x = int : 0 |
$x = int : -1 |
0 | -1 | -2 | -1 | 1 |
-1 | -1 |
-1 |
-1 |
0 |
$x = int : -1 |
$x = int : 42 |
43 | 42 | 41 | 42 | -42 |
42 | 42 |
42 |
42 |
0 |
$x = int : 42 |
†i8$x = int : 13369593 |
13369594 | 13369593 | 13369592 | 13369593 | -13369593 |
13369593 | 13369593 |
13369593 |
13369593 |
0 |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
43 | 42 | 41 | 42 | -42 |
42 | 42 |
42 |
42 |
0 |
†i9$x = int : 42 |
$x = float : 1.3 |
2.3 | 1.3 | 0.3 | 1.3 | -1.3 |
1.3 | 1.3 |
1.3 |
1.3 |
0 |
$x = float : 1.3 |
$x = float : 0.005 |
1.005 | 0.005 | -0.995 | 0.005 | -0.005 |
0.005 | 0.005 |
0.005 |
0.005 |
0 |
$x = float : 0.005 |
$x = float : 0 |
1 | 0 | -1 | 0 | 0 |
0 | 0 |
0 |
0 |
0 |
$x = float : 0 |
$x = float : -1.3 |
-0.3 | -1.3 | -2.3 | -1.3 | 1.3 |
-1.3 | -1.3 |
-1.3 |
-1.3 |
0 |
$x = float : -1.3 |
†f5$x = float : NAN |
NAN | NAN | NAN | NAN | NAN |
NAN | NAN |
NAN |
NAN |
0 |
†f5$x = float : NAN |
†f6$x = float : NAN |
NAN | NAN | NAN | NAN | NAN |
NAN | NAN |
NAN |
NAN |
0 |
†f6$x = float : NAN |
†f7$x = float : -INF |
-INF | -INF | -INF | -INF | INF |
-INF | -INF |
-INF |
-INF |
0 |
†f7$x = float : -INF |
†f8$x = float : INF |
INF | INF | INF | INF | -INF |
INF | INF |
INF |
INF |
0 |
†f8$x = float : INF |
†f9$x = float : 123450000 |
123450001 | 123450000 | 123449999 | 123450000 | -123450000 |
123450000 | 123450000 |
123450000 |
123450000 |
0 |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
‘1’ |
‘’ |
-1 | ‘’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
‘ ’ |
‘ ’ |
‘ ’ |
‘ ’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
2 | ‘ 1’ |
0 | ‘ 1’ |
-1 |
1 | 1 |
1 |
1 |
0 |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
‘ 3 ’ |
‘ 3 ’ |
‘ 3 ’ |
‘ 3 ’ |
-3 |
3 | 3 |
3 |
3 |
0 |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
2 | ‘1’ |
0 | ‘1’ |
-1 |
1 | 1 |
1 |
1 |
0 |
$x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
1 | ‘0’ |
-1 | ‘0’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
0 | ‘-1’ |
-2 | ‘-1’ |
1 |
-1 | -1 |
-1 |
-1 |
0 |
$x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
43 | ‘42’ |
41 | ‘42’ |
-42 |
42 | 42 |
42 |
42 |
0 |
$x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
2.3 | ‘1.3’ |
0.3 | ‘1.3’ |
-1.3 |
1.3 | 1.3 |
1.3 |
1.3 |
0 |
$x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
1 | ‘0.0’ |
-1 | ‘0.0’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
-0.305 | ‘-1.305’ |
-2.305 | ‘-1.305’ |
1.305 |
-1.305 | -1.305 |
-1.305 |
-1.305 |
0 |
$x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
‘truf’ |
‘true’ |
‘true’ |
‘true’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
‘falsf’ |
‘false’ |
‘false’ |
‘false’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
‘nulm’ |
‘null’ |
‘null’ |
‘null’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
‘123sts’ |
‘123str’ |
‘123str’ |
‘123str’ |
-123 |
123 | 123 |
123 |
123 |
0 |
$x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
‘str124’ |
‘str123’ |
‘str123’ |
‘str123’ |
0 |
0 | 0 |
0 |
0 |
0 |
$x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
‘123, "str"’ |
‘123, "str"’ |
‘123, "str"’ |
‘123, "str"’ |
-123 |
123 | 123 |
123 |
123 |
0 |
$x = string[10] : ‘123, "str"’ |
$x = string[8] : ‘0xCC00F9’ |
13369594 | ‘0xCC00F9’ |
13369592 | ‘0xCC00F9’ |
-13369593 |
13369593 | 13369593 |
13369593 |
13369593 |
0 |
$x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
124 | ‘0123’ |
122 | ‘0123’ |
-123 |
123 | 123 |
123 |
123 |
0 |
$x = string[4] : ‘0123’ |
$x = array() |
array() |
array() |
array() |
array() |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
0 |
$x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Array: ( [1] => ‘string’ ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
0 |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Array: ( [0] => b false [1] => 1 [2] => 1.3 [3] => ‘123str’ [4] => ‘str123’ [5] => null ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
Fatal error ( #2 ) |
0 |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
Object:
( Class: stdClass ( ) ) |
-1 ( #3 ) |
1
( #3 ) |
1 ( #3 ) |
1 ( #3 ) |
1 ( #3 ) |
0 ( #3 ) |
$x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
Object:
( Class: TestObjectToString ( property: test3 = ‘some string’ property: test1 = null property: test2 = b true method: __toString method: print_it ) ) |
-1 ( #3 ) |
1
( #3 ) |
1 ( #3 ) |
1 ( #3 ) |
1 ( #3 ) |
0 ( #3 ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #83 ( = RESOURCE ) |
Resource id #83 |
Resource id #83 |
Resource id #83 |
Resource id #83 |
-83 |
83 | 83 |
83 |
83 |
0 |
$x = resource : Resource id #83 ( = RESOURCE ) |
- Notice: Undefined index: notset
- Fatal error: Unsupported operand types
- Notice: Object of class stdClass/TestObject/TestObjectToString could not be converted to int
Please take note: using the in-/decrementors on SplInt and SplFloat objects may give unexpected (inconsistent) results....
CType Extension | ctype_digit() ‡1 | ctype_xdigit() ‡1 | ctype_alpha() ‡1 | ctype_alnum() ‡1 | ctype_graph() ‡1 | ctype_print() ‡1 | ctype_lower() ‡1 | ctype_upper() ‡1 | ctype_cntrl() ‡1 | ctype_punct() ‡1 | ctype_space() ‡1 | CType Extension |
---|---|---|---|---|---|---|---|---|---|---|---|---|
CType Extension | ctype_digit() ‡1 | ctype_xdigit() ‡1 | ctype_alpha() ‡1 | ctype_alnum() ‡1 | ctype_graph() ‡1 | ctype_print() ‡1 | ctype_lower() ‡1 | ctype_upper() ‡1 | ctype_cntrl() ‡1 | ctype_punct() ‡1 | ctype_space() ‡1 | CType Extension |
$x = null : ( = NULL ) |
false | false | false | false | false | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = null : ( = NULL ) |
false | false | false | false | false | false | false | false | false | false | false | $x = null : ( = NULL ) |
$x = bool : ( = false ) |
false | false | false | false | false | false | false | false | false | false | false | $x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
false | false | false | false | false | false | false | false | false | false | false | $x = bool : 1 ( = true ) |
$x = int : 1 |
false | false | false | false | false | false | false | false | true | false | false | $x = int : 1 |
$x = int : 0 |
false | false | false | false | false | false | false | false | true | false | false | $x = int : 0 |
$x = int : -1 |
false | false | false | false | false | false | false | false | false | false | false | $x = int : -1 |
$x = int : 10 |
false | false | false | false | false | false | false | false | true | false | true | $x = int : 10 |
$x = int : 42 |
false | false | false | false | true | true | false | false | false | true | false | $x = int : 42 |
$x = int : 111 |
false | false | true | true | true | true | true | false | false | false | false | $x = int : 111 |
$x = int : 12345 |
true | true | false | true | true | true | false | false | false | false | false | $x = int : 12345 |
†i8$x = int : 13369593 |
true | true | false | true | true | true | false | false | false | false | false | †i8$x = int : 13369593 |
†i9$x = int : 42 |
false | false | false | false | true | true | false | false | false | true | false | †i9$x = int : 42 |
$x = float : 1.3 |
false | false | false | false | false | false | false | false | false | false | false | $x = float : 1.3 |
$x = float : 0.005 |
false | false | false | false | false | false | false | false | false | false | false | $x = float : 0.005 |
$x = float : 0 |
false | false | false | false | false | false | false | false | false | false | false | $x = float : 0 |
$x = float : -1.3 |
false | false | false | false | false | false | false | false | false | false | false | $x = float : -1.3 |
†f5$x = float : NAN |
false | false | false | false | false | false | false | false | false | false | false | †f5$x = float : NAN |
†f6$x = float : NAN |
false | false | false | false | false | false | false | false | false | false | false | †f6$x = float : NAN |
†f7$x = float : -INF |
false | false | false | false | false | false | false | false | false | false | false | †f7$x = float : -INF |
†f8$x = float : INF |
false | false | false | false | false | false | false | false | false | false | false | †f8$x = float : INF |
†f9$x = float : 123450000 |
false | false | false | false | false | false | false | false | false | false | false | †f9$x = float : 123450000 |
$x = string[0] : ‘’ |
false | false | false | false | false | false | false | false | false | false | false | $x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
false | false | false | false | false | true | false | false | false | false | true | $x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
false | false | false | false | false | true | false | false | false | false | false | $x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
false | false | false | false | false | true | false | false | false | false | false | $x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
true | true | false | true | true | true | false | false | false | false | false | $x = string[1] : ‘1’ |
$x = string[1] : ‘0’ |
true | true | false | true | true | true | false | false | false | false | false | $x = string[1] : ‘0’ |
$x = string[2] : ‘-1’ |
false | false | false | false | true | true | false | false | false | false | false | $x = string[2] : ‘-1’ |
$x = string[2] : ‘42’ |
true | true | false | true | true | true | false | false | false | false | false | $x = string[2] : ‘42’ |
$x = string[3] : ‘1.3’ |
false | false | false | false | true | true | false | false | false | false | false | $x = string[3] : ‘1.3’ |
$x = string[3] : ‘0.0’ |
false | false | false | false | true | true | false | false | false | false | false | $x = string[3] : ‘0.0’ |
$x = string[6] : ‘-1.305’ |
false | false | false | false | true | true | false | false | false | false | false | $x = string[6] : ‘-1.305’ |
$x = string[4] : ‘true’ |
false | false | true | true | true | true | true | false | false | false | false | $x = string[4] : ‘true’ |
$x = string[5] : ‘false’ |
false | false | true | true | true | true | true | false | false | false | false | $x = string[5] : ‘false’ |
$x = string[4] : ‘null’ |
false | false | true | true | true | true | true | false | false | false | false | $x = string[4] : ‘null’ |
$x = string[6] : ‘123str’ |
false | false | false | true | true | true | false | false | false | false | false | $x = string[6] : ‘123str’ |
$x = string[6] : ‘str123’ |
false | false | false | true | true | true | false | false | false | false | false | $x = string[6] : ‘str123’ |
$x = string[10] : ‘123, "str"’ |
false | false | false | false | false | true | false | false | false | false | false | $x = string[10] : ‘123, "str"’ |
$x = string[9] : ‘123,"str"’ |
false | false | false | false | true | true | false | false | false | false | false | $x = string[9] : ‘123,"str"’ |
†sk$x = string[12] : ‘123, "str"
’ |
false | false | false | false | false | false | false | false | false | false | false | †sk$x = string[12] : ‘123, "str"
’ |
$x = string[6] : ‘AF036C’ |
false | true | false | true | true | true | false | false | false | false | false | $x = string[6] : ‘AF036C’ |
$x = string[3] : ‘FOO’ |
false | false | true | true | true | true | false | true | false | false | false | $x = string[3] : ‘FOO’ |
†sn$x = string[4] : ‘
’ |
false | false | false | false | false | false | false | false | true | false | true | †sn$x = string[4] : ‘
’ |
$x = string[5] : ‘*&$()’ |
false | false | false | false | true | true | false | false | false | true | false | $x = string[5] : ‘*&$()’ |
†sp$x = string[4] : ‘
’ |
false | false | false | false | false | false | false | false | true | false | false | †sp$x = string[4] : ‘
’ |
$x = string[8] : ‘0xCC00F9’ |
false | false | false | true | true | true | false | false | false | false | false | $x = string[8] : ‘0xCC00F9’ |
$x = string[4] : ‘0123’ |
true | true | false | true | true | true | false | false | false | false | false | $x = string[4] : ‘0123’ |
$x = string[27] : ‘Iñtërnâtiônàlizætiøn’ |
false | false | false | false | false | false | false | false | false | false | false | $x = string[27] : ‘Iñtërnâtiônàlizætiøn’ |
$x = array() |
false | false | false | false | false | false | false | false | false | false | false | $x = array() |
$x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
false | false | false | false | false | false | false | false | false | false | false | $x = Array: ( [1 (int)] => string[6] : ‘string’ ) |
$x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
false | false | false | false | false | false | false | false | false | false | false | $x = Array: ( [0 (int)] => bool : ( = false ) [1 (int)] => int : 1 [2 (int)] => float : 1.3 [3 (int)] => string[6] : ‘123str’ [4 (int)] => string[6] : ‘str123’ [5 (int)] => null : ( = NULL ) ) |
$x = Object:
( Class: stdClass ( ) ) |
false | false | false | false | false | false | false | false | false | false | false | $x = Object:
( Class: stdClass ( ) ) |
$x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
false | false | false | false | false | false | false | false | false | false | false | $x = Object:
( Class: TestObjectToString ( property: test3 = string[11] : ‘some string’ property: test1 = null : ( = NULL ) property: test2 = bool : 1 ( = true ) method: __toString method: print_it ) ) |
$x = resource : Resource id #86 ( = RESOURCE ) |
false | false | false | false | false | false | false | false | false | false | false | $x = resource : Resource id #86 ( = RESOURCE ) |
- Notice: Undefined index: notset
Important: Integers between -128 and 255 are interpreted as the ASCII value pointing to a character (negative values have 256 added in order to allow characters in the Extended ASCII range).
In any other case, integers are interpreted as a string containing the decimal digits of the integer.
Filter Extension - bool/int/float | filter_var (…) ‡1 ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | Filter Extension - bool/int/float |
---|---|---|---|---|---|---|---|---|---|
Filter Extension - bool/int/float | filter_var (…) ‡1 ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | filter_var (…) ‡2 | Filter Extension - bool/int/float |
$x = null : ( = NULL ) |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
$x = null : ( = NULL ) |
$x = null : ( = NULL ) |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
$x = null : ( = NULL ) |
$x = bool : ( = false ) |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
$x = bool : ( = false ) |
$x = bool : 1 ( = true ) |
true | 1 | 1 | 1 | ‘1’ |
1 | ‘1’ |
‘1’ |
$x = bool : 1 ( = true ) |
$x = int : 1 |
true | 1 | 1 | 1 | ‘1’ |
1 | ‘1’ |
‘1’ |
$x = int : 1 |
$x = int : 0 |
false | 0 | null | 0 | ‘0’ |
0 | ‘0’ |
‘0’ |
$x = int : 0 |
$x = int : -1 |
null | -1 | null | -1 | ‘-1’ |
-1 | ‘-1’ |
‘-1’ |
$x = int : -1 |
$x = int : 42 |
null | 42 | 42 | 42 | ‘42’ |
42 | ‘42’ |
‘42’ |
$x = int : 42 |
†i8$x = int : 13369593 |
null | 13369593 | null | 13369593 | ‘13369593’ |
13369593 | ‘13369593’ |
‘13369593’ |
†i8$x = int : 13369593 |
†i9$x = int : 42 |
null | 42 | 42 | 42 | ‘42’ |
42 | ‘42’ |
‘42’ |
†i9$x = int : 42 |
$x = float : 1.3 |
null | null | null | null | ‘13’ |
1.3 | ‘13’ |
‘1.3’ |
$x = float : 1.3 |
$x = float : 0.005 |
null | null | null | null | ‘0005’ |
0.005 | ‘0005’ |
‘0.005’ |
$x = float : 0.005 |
$x = float : 0 |
false | 0 | null | 0 | ‘0’ |
0 | ‘0’ |
‘0’ |
$x = float : 0 |
$x = float : -1.3 |
null | null | null | null | ‘-13’ |
-1.3 | ‘-13’ |
‘-1.3’ |
$x = float : -1.3 |
†f5$x = float : NAN |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
†f5$x = float : NAN |
†f6$x = float : NAN |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
†f6$x = float : NAN |
†f7$x = float : -INF |
null | null | null | null | ‘-’ |
null | ‘-’ |
‘-’ |
†f7$x = float : -INF |
†f8$x = float : INF |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
†f8$x = float : INF |
†f9$x = float : 123450000 |
null | 123450000 | null | 123450000 | ‘123450000’ |
123450000 | ‘123450000’ |
‘123450000’ |
†f9$x = float : 123450000 |
$x = string[0] : ‘’ |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
$x = string[0] : ‘’ |
$x = string[1] : ‘ ’ |
null | null | null | null | ‘’ |
null | ‘’ |
‘’ |
$x = string[1] : ‘ ’ |
$x = string[2] : ‘ 1’ |
true | 1 | 1 | 1 | ‘1’ |
1 | ‘1’ |
‘1’ |
$x = string[2] : ‘ 1’ |
$x = string[3] : ‘ 3 ’ |
null | 3 | 3 | 3 | ‘3’ |
3 | ‘3’ |
‘3’ |
$x = string[3] : ‘ 3 ’ |
$x = string[1] : ‘1’ |
true | 1 | 1 | 1 | ‘1’ |