3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
#000000 Warning: Undefined array key 1 in /in/Q5kCF on line 14 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/Q5kCF on line 15 Fatal error: Uncaught TypeError: dechex(): Argument #1 ($num) must be of type int, string given in /in/Q5kCF:19 Stack trace: #0 /in/Q5kCF(19): dechex('') #1 /in/Q5kCF(26): swift_rgb2hex(Array) #2 {main} thrown in /in/Q5kCF on line 19
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.12 ms | 401 KiB | 8 Q