3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $shuZhu=array(array("经理1","经理2"),array("主管1","主管2","经理3"),array("组长","老大")); $fontPosition='simhei.ttf'; class process { var $arr;//流程确定的数组 var $promoters;//流程发起人 var $black;//所画节点颜色 var $imgWidth;//图片宽度 var $imgHeight;//图片长度 var $font;//字体存放位置 var $fontSize; function __construct($shuZhu,$fontP,$width=400,$height=300,$fontSize=10,$promoters="") { $this->arr=$shuZhu; $this->promoters=$promoters; $this->font = $fontP; $this->imgWidth=$width; $this->imgHeight=$height; $this->fontSize=$fontSize; } //point(x1,x2)是画图的起始点,w是横线的长,h是竖线的长,r是节点圆点的半径 function show( $x,$y,$w,$h,$r) { //创建画布 $image=imagecreatetruecolor($this->imgWidth,$this->imgHeight); //设置图像中所需的颜色 $gray=imagecolorallocate($image,0xc0,0xC0,0xC0); $red=imagecolorallocate($image,0xFF,0x00,0x00); $black=imagecolorallocate($image,0x00,0x00,0x00); imagefill($image,0,0,$gray); imageline($image,$x,$y,$x+$w,$y,$red);//画第一条横线线 imagefilledellipse($image, $x,$y, $r,$r, $black);//画出发起人的节点 imagettftext($image,$this->fontSize, 0, $x-$w/4,$y+$w/2, $black, $this->font,$this->promoters); for($i=0;$i<count($this->arr);$i++) { $num=count($this->arr[$i]);//该级接点上有多少人 if($num>1)//节点上的人数多于一人,则先画一条竖线 { imageline($image,$x+$w*($i+1),$y-$h/2,$x+$w*($i+1),$y+$h/2,$red); } for($j=0;$j<count($this->arr[$i]);$j++) { if($num>1) { $m=$h/($num-1);//一个节点上有count[$arr[i]]个人,则$m代表截取竖线的长度 imageline($image,$x+$w*($i+1),$y-$h/2+$m*$j,$x+$w*($i+2),$y,$red); imagefilledellipse($image, $x+$w*($i+1),$y-$h/2+$m*$j, $r,$r, $black); //imagestring($image,2,$x+$w*($i+1)-10,$y-$h/2+$m*$j+5,$this->arr[$i][$j],$black);//直接输出接点上的人员名称 imagettftext($image, $this->fontSize, 0, $x+$w*($i+1)-$w/4,$y-$h/2+$m*$j+$w/2, $black, $this->font, $this->arr[$i][$j]); } else { imageline($image,$x+$w*($i+1),$y,$x+$w*($i+2),$y,$red);//画一条横线 imagefilledellipse($image, $x+$w*($i+1),$y, $r,$r, $black); //imagestring($image,2,$x+$w*($i+1),$y,$this->arr[$i][0],$black);//直接输出接点上的人员名称 imagettftext($image,$this->fontSize, 0, $x+$w*($i+1)-$w/4,$y+$w/2, $black, $this->font,$this->arr[$i][0]); } } } header('Content-type:image/png'); imagepng($image); imagedestroy($image); } } $img=new process($shuZhu,$fontPosition,600,300,10,"董事长"); $img->show(10,150,50,200,8); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function imagecreatetruecolor() in /in/fjqTq:27 Stack trace: #0 /in/fjqTq(73): process->show(10, 150, 50, 200, 8) #1 {main} thrown in /in/fjqTq on line 27
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: No such file or directory in /in/fjqTq on line 37 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 37 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 Warning: No such file or directory in /in/fjqTq on line 54 Warning: Invalid font filename simhei.ttf in /in/fjqTq on line 54 �PNG  IHDRX,�_Z� IDATx���K��FDQȡ}�K�W&Z��C� ��s&�'�Փh�X�u�V=�$�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�j?����tz�a]�#w|d������~>�U�)�__��*�� �K��U�&�� B@�aBx�{��~�*�� ���;��[0��B�||�7���5X�eY�ײ��Ϻ��5H�5^��a�c�@�!�i�f:V�b��=fa�c�f!�6I3��MB�g�f:V��'���T!�<t�H6U`��B�y�Xk��&�0�б ӄ!�����C�*�@s�n4m3��LB���!�<t��2s�[��0�б ��!���a�c@��CWT�0�б AE�f:V�%�pVQ3��UB��+����U� !|R��C�*��ԅ�k a�c�!C��0�б �JCozC�y�X�b�!��<����U�TBha�c�˴��rBz�X�B@5!\��C�*�B� �o���U�&�T�e:V<�PM?�<t�x!��~�y�X�$B@5!<#�б ���jBx^�c�� !Մ��C�*��B� �5���U$�T�od:V<�PM��y�X�B@5!�I�c����jBx��C�*�; !Մp��C�*�{!Մp��C�*�݄�jB�Y�c�>B@5!�#�б `!���y�X��PM��<t��D�&�w�<t���PM�y�Xp��W���7k]�L����t�Y���Exz�;����_����9�U�� hv>�__�=�� `hgBx����Y��紎B ʵ�#��u;����0���1 �U�������9�G�����_��Fw��2_�q/�%��U�ᕹ hv�?�x�����~���g0�kG�M��ۉ���:Qc��\��X���%�ı �vB@5!�/�ı `!���y�X��PM��<q��A�&��e�8V�#�T�m2O�vB� ��'�U�B� �2O��$�T›d�8V�O�&���<q�x!��~#�ı �Q��jBxM�c� !Մ���*��B� �y�'�U'�T�32O��A�&��e�8V<�PM?�<q�x!���/�ı ੄�jB�[�c�� !ՄpYRO�^@�&��'�U�!�Tka�c�˴��r�!�<q�x��@o3O�^�7��Ԇ0�ı �JCoC�y�Xp���u!�<q�8J]཮f�8V�+��IQ3O��UB��%��'�U�k !�U���*�!�K�a�c@��CWL���*�����9��'�UQf!|k�f�8V��6�p�9C�y�Xh���& a�c@� C��-��'�U�f !l2U3O��MB�j�f�8V��'���$!�<q��7I`�B�y�X0�B� ���*�Q B���!�<q���!�; ���*���<z�f������U��"���/˲,?���U�)��_�K��zV m�^zǏ}߭�0!�gB� �·�/��kX0�aB��{�^v��6R���y��n��~x"h6�E�%�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !Մ�jB@5!��PM�&�TB� !� f��#cIEND�B`�
Output for 5.2.3 - 5.6.28
Fatal error: Call to undefined function imagecreatetruecolor() in /in/fjqTq on line 27
Process exited with code 255.
Output for 5.0.0 - 5.2.2
<br /> <b>Fatal error</b>: Call to undefined function imagecreatetruecolor() in <b>/in/fjqTq</b> on line <b>27</b><br />
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: imagecreatetruecolor() in <b>/in/fjqTq</b> on line <b>27</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: imagecreatetruecolor() in <b>/in/fjqTq</b> on line <b>27</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: imagecreatetruecolor() in <b>/in/fjqTq</b> on line <b>27</b><br />