3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name = "Anthony"; var_dump( mb_substr(new stdClass, 0, 7), mb_substr($name, "a", 20), mb_substr($name, 20, "b") );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
Fatal error: Uncaught TypeError: mb_substr(): Argument #1 ($string) must be of type string, stdClass given in /in/sH51s:5 Stack trace: #0 /in/sH51s(5): mb_substr(Object(stdClass), 0, 7) #1 {main} thrown in /in/sH51s on line 5
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught TypeError: mb_substr(): Argument #1 ($string) must be of type string, stdClass given in /in/sH51s:5 Stack trace: #0 /in/sH51s(5): mb_substr(Object(stdClass), 0, 7) #1 {main} thrown in /in/sH51s on line 5
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: mb_substr() expects parameter 1 to be string, object given in /in/sH51s on line 5 Warning: mb_substr() expects parameter 2 to be int, string given in /in/sH51s on line 6 Warning: mb_substr() expects parameter 3 to be int, string given in /in/sH51s on line 7 NULL NULL NULL

preferences:
150.01 ms | 402 KiB | 157 Q