3v4l.org

run code in 300+ PHP versions simultaneously
<?php global $statement; $db = new PDO('sqlite:/tmp/tmp.db', 'test', 'test'); $statement = $db->prepare('select 1 where 1 = :a'); function wrapper(string $param, mixed $value, int $type = PDO::PARAM_STR, int $maxLength = null, mixed $driverOptions = null) { $statement = $GLOBALS['statement']; var_dump('wrapper: ', \func_get_args()); var_dump('wrapper slice-3: ', \array_slice(\func_get_args(), 3)); $statement->bindParam($param, $value, $type, ...\array_slice(\func_get_args(), 3)); } echo 'wrapper("a",2)', PHP_EOL; wrapper("a",2); echo 'wrapper("a",2,PDO::PARAM_INT)', PHP_EOL; wrapper("a",2,PDO::PARAM_INT); echo 'wrapper("a","foo",PDO::PARAM_INT)', PHP_EOL; wrapper("a","foo",PDO::PARAM_INT); echo 'wrapper("a","foo",PDO::PARAM_INT,3)', PHP_EOL; wrapper("a","foo",PDO::PARAM_INT,3); echo 'wrapper("a","foo",PDO::PARAM_INT,null)', PHP_EOL; wrapper("a","foo",PDO::PARAM_INT,null);
Output for 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Deprecated: wrapper(): Implicitly marking parameter $maxLength as nullable is deprecated, the explicit nullable type must be used instead in /in/biaIs on line 7 wrapper("a",2) string(9) "wrapper: " array(2) { [0]=> string(1) "a" [1]=> int(2) } string(17) "wrapper slice-3: " array(0) { } wrapper("a",2,PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> int(2) [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT,3) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> int(3) } string(17) "wrapper slice-3: " array(1) { [0]=> int(3) } wrapper("a","foo",PDO::PARAM_INT,null) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> NULL } string(17) "wrapper slice-3: " array(1) { [0]=> NULL } Deprecated: PDOStatement::bindParam(): Passing null to parameter #4 ($maxLength) of type int is deprecated in /in/biaIs on line 13
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
wrapper("a",2) string(9) "wrapper: " array(2) { [0]=> string(1) "a" [1]=> int(2) } string(17) "wrapper slice-3: " array(0) { } wrapper("a",2,PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> int(2) [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT,3) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> int(3) } string(17) "wrapper slice-3: " array(1) { [0]=> int(3) } wrapper("a","foo",PDO::PARAM_INT,null) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> NULL } string(17) "wrapper slice-3: " array(1) { [0]=> NULL } Deprecated: PDOStatement::bindParam(): Passing null to parameter #4 ($maxLength) of type int is deprecated in /in/biaIs on line 13
Output for 8.0.1 - 8.0.30
wrapper("a",2) string(9) "wrapper: " array(2) { [0]=> string(1) "a" [1]=> int(2) } string(17) "wrapper slice-3: " array(0) { } wrapper("a",2,PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> int(2) [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT) string(9) "wrapper: " array(3) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) } string(17) "wrapper slice-3: " array(0) { } wrapper("a","foo",PDO::PARAM_INT,3) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> int(3) } string(17) "wrapper slice-3: " array(1) { [0]=> int(3) } wrapper("a","foo",PDO::PARAM_INT,null) string(9) "wrapper: " array(4) { [0]=> string(1) "a" [1]=> string(3) "foo" [2]=> int(1) [3]=> NULL } string(17) "wrapper slice-3: " array(1) { [0]=> NULL }
Output for 7.4.0 - 7.4.33
wrapper("a",2) Fatal error: Uncaught TypeError: Argument 2 passed to wrapper() must be an instance of mixed, int given, called in /in/biaIs on line 17 and defined in /in/biaIs:7 Stack trace: #0 /in/biaIs(17): wrapper('a', 2) #1 {main} thrown in /in/biaIs on line 7
Process exited with code 255.

preferences:
131.02 ms | 415 KiB | 5 Q