3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $color = "#acb"; $color = substr($color,1); if (strlen($color) == 3) { $r = substr($color,0,1); $g = substr($color,1,1); $b = substr($color,2,1); } elseif (strlen($color) == 6) { $r = substr($color,0,2); $g = substr($color,2,2); $b = substr($color,4,2); } else { throw new Exception('Invalid color format'); } var_dump($r,$g,$b);
based on X7Oeh
Output for 5.0.0 - 7.1.0
string(1) "a" string(1) "c" string(1) "b"
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/BQYGt on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_NEW in /in/BQYGt on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/BQYGt on line 15
Process exited with code 255.