3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = [null]; echo 'null, valid cast: ' . array_product($a) . "\n\n"; $a = [false]; echo 'false, valid cast: ' . array_product($a) . "\n\n"; $a = [true]; echo 'true, valid cast: ' . array_product($a) . "\n\n"; $a = ['']; echo 'empty string, invalid cast: ' . array_product($a) . "\n\n"; $a = ['42.5']; echo 'string of a float, valid cast: ' . array_product($a) . "\n\n"; $a = ['42,5']; echo 'string of comma-separated float, valid cast but not desirable (discards trailing chars): ' . array_product($a) . "\n\n"; $a = ['42a']; echo 'string of int with trailing alpha char, valid cast but not desirable (discards trailing chars): ' . array_product($a) . "\n\n"; $a = ['a42']; echo 'string of int with leading alpha char, invalid cast: ' . array_product($a) . "\n\n"; $a = [[]]; echo 'array, invalid cast: ' . array_product($a) . "\n\n"; $a = [new stdClass()]; echo 'class that does not auto-cast, invalid cast: ' . array_product($a) . "\n\n"; $a = [gmp_init(42)]; echo 'gmp, valid cast: ' . array_product($a) . "\n\n";
Output for git.master_jit, git.master
null, valid cast: 0 false, valid cast: 0 true, valid cast: 1 Warning: array_product(): Multiplication is not supported on type string in /in/KdkVP on line 13 empty string, invalid cast: 0 string of a float, valid cast: 42.5 Warning: A non-numeric value encountered in /in/KdkVP on line 19 string of comma-separated float, valid cast but not desirable (discards trailing chars): 42 Warning: A non-numeric value encountered in /in/KdkVP on line 22 string of int with trailing alpha char, valid cast but not desirable (discards trailing chars): 42 Warning: array_product(): Multiplication is not supported on type string in /in/KdkVP on line 25 string of int with leading alpha char, invalid cast: 0 Warning: array_product(): Multiplication is not supported on type array in /in/KdkVP on line 28 array, invalid cast: 1 Warning: array_product(): Multiplication is not supported on type stdClass in /in/KdkVP on line 31 class that does not auto-cast, invalid cast: 1 gmp, valid cast: 42

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.16 ms | 904 KiB | 4 Q