3v4l.org

run code in 300+ PHP versions simultaneously
<?php function msgme(&$message) { foreach (is_array($message) ? $message : [&$message] as &$field) { $field = 'We are cool!'; } } $m1 = "Shit happened\n"; msgme($m1); print $m1; print "\n\n"; $m2 = ['t1'=>'Shit happened']; msgme($m2); print_r($m2);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
We are cool! Array ( [t1] => Shit happened )
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
We are cool! Array ( [t1] => We are cool! )

preferences:
112.03 ms | 1792 KiB | 4 Q