3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo {} function type_null( null $a ) { return $a; } function type_array( array $a ) { return $a; } function type_Foo( Foo $a ) { return $a; } function return_type_array( array $a ): array { return null; } function return_type_null( array $a ): null { return $a; } type_null( 'a' ); //type_array( 'a' ); //type_Foo( new stdClass() ); //return_type_array( array() ); //return_type_null( array() );
Output for 8.2.28 - 8.2.32, 8.3.5 - 8.3.33, 8.4.5 - 8.4.24, 8.5.0 - 8.5.9
Fatal error: Uncaught TypeError: type_null(): Argument #1 ($a) must be of type null, string given, called in /in/f0gTa on line 26 and defined in /in/f0gTa:6 Stack trace: #0 /in/f0gTa(26): type_null('a') #1 {main} thrown in /in/f0gTa on line 6
Process exited with code 255.
Output for 8.1.34
Fatal error: Null can not be used as a standalone type in /in/f0gTa on line 6
Process exited with code 255.

preferences:
69.36 ms | 690 KiB | 4 Q