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.3
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.13
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.26
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.