3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $limited_email_domains ) { $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); var_dump( gettype( $limited_email_domains ) ); } test( 0 ); test( false ); test( '' ); test( array( 'foo', 'bar', 'baz' ) ); // This one will throw a fatal error as str_replace's third param must be string or array. test( (object) array( 'foo', 'bar', 'baz' ) );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
string(6) "string" string(6) "string" string(6) "string" string(5) "array" Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, stdClass given in /in/Lfmgp:4 Stack trace: #0 /in/Lfmgp(4): str_replace(' ', '\n', Object(stdClass)) #1 /in/Lfmgp(15): test(Object(stdClass)) #2 {main} thrown in /in/Lfmgp on line 4
Process exited with code 255.
Output for 7.4.0 - 7.4.33
string(6) "string" string(6) "string" string(6) "string" string(5) "array" Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/Lfmgp:4 Stack trace: #0 /in/Lfmgp(4): str_replace(' ', '\n', Object(stdClass)) #1 /in/Lfmgp(15): test(Object(stdClass)) #2 {main} thrown in /in/Lfmgp on line 4
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33
string(6) "string" string(6) "string" string(6) "string" string(5) "array" Recoverable fatal error: Object of class stdClass could not be converted to string in /in/Lfmgp on line 4
Process exited with code 255.

preferences:
175.82 ms | 402 KiB | 179 Q