3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function swift_rgb2hex($rgb,$hash=true) { if($rgb == NULL){ return 'none'; } if($hash) $hex = '#'; $temp = explode('(',$rgb); if(!is_array($temp)){ return $rgb; } $rgb = $temp[1]; $temp = explode(')',$rgb); $rgb = $temp[0]; $rgb = explode(',',$rgb); $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); return $hex; } echo swift_rgb2hex('rgba(0,0,0)'); echo swift_rgb2hex('boom'); echo swift_rgb2hex('FFFFFF'); echo swift_rgb2hex('rgba(0,0,0)');
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
#000000 Notice: Undefined offset: 1 in /in/Q5kCF on line 14 Notice: Undefined offset: 1 in /in/Q5kCF on line 20 Notice: Undefined offset: 2 in /in/Q5kCF on line 21 #000000 Notice: Undefined offset: 1 in /in/Q5kCF on line 14 Notice: Undefined offset: 1 in /in/Q5kCF on line 20 Notice: Undefined offset: 2 in /in/Q5kCF on line 21 #000000#000000
Output for hhvm-3.10.0 - 3.12.0
#000000 Notice: Undefined index: 1 in /in/Q5kCF on line 14 Notice: Undefined index: 1 in /in/Q5kCF on line 20 Notice: Undefined index: 2 in /in/Q5kCF on line 21 #000000 Notice: Undefined index: 1 in /in/Q5kCF on line 14 Notice: Undefined index: 1 in /in/Q5kCF on line 20 Notice: Undefined index: 2 in /in/Q5kCF on line 21 #000000#000000
Output for 4.3.0 - 5.2.17
#000000 Notice: Undefined offset: 1 in /in/Q5kCF on line 14 Notice: Undefined offset: 1 in /in/Q5kCF on line 20 Notice: Undefined offset: 2 in /in/Q5kCF on line 21 #000000 Notice: Undefined offset: 1 in /in/Q5kCF on line 14 Notice: Undefined offset: 1 in /in/Q5kCF on line 20 Notice: Undefined offset: 2 in /in/Q5kCF on line 21 #000000#000000