3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Global variable referenced by following function. // If we had another function that used this name, now it'd be an array and it could break it. $name = 'Ryan McDermott'; function splitIntoFirstAndLastName() { $name = preg_split('/ /', $name); } splitIntoFirstAndLastName(); var_dump($name); // ['Ryan', 'McDermott'];
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Undefined variable $name in /in/pmVQM on line 8 Deprecated: preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/pmVQM on line 8 string(14) "Ryan McDermott"
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $name in /in/pmVQM on line 8 string(14) "Ryan McDermott"
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: name in /in/pmVQM on line 8 string(14) "Ryan McDermott"
Output for 7.3.32 - 7.3.33
string(14) "Ryan McDermott"

preferences:
223.33 ms | 401 KiB | 293 Q