3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.20, 7.1.0 - 7.1.25, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 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.0.5, 5.1.0 - 5.1.6, 5.2.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.3.11, 4.4.0 - 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 />

preferences:
254.06 ms | 402 KiB | 359 Q