찾다
백엔드 개발PHP 튜토리얼PHP轻量级图表类PHP Light Chart:PLChart

 

该类可以生成饼状图(2D/3D),柱状图(2D/3D),以及折线图,可控制输出至浏览器或文件,控制输出的jpeg图像的质量。
所有的设置工作只有5个函数:
1。图表背景色设置setbgcolor()
2。图表参数设置setchartdata()
2。图表标题设置settitle()
3。图表注释设置setdesc()
4。图表图形设置setgraphics()

详细的设置参数请参考文档注释或是后面的测试页面demo.php

<?php /** * PLChart - PHP图表生成工具 - Create charts in PHP * * ==================================================================== * Filename : plchart.php * Summary: PLChart图表类文件 - PLChart class file * Author: zeroleonhart ( msn:zeroleonhart@hotmail.com ) * Version: 0.060811 * Copyright (c)2006 zeroleonhart@hotmail.com * ==================================================================== * * */class plchart {  // ============================ 参数定义 - define references ============================ // 图表变量 - chart variable var $chart; // 图表类型 - chart type var $type; // 3D效果 - 3D effect var $d3d; // 图表宽度 - chart width var $width; // 图表高度 - chart height var $height; // 图表质量 - chart quality var $quality;  // 图表背景色 - image backgroundcolor var $bgcolor = array();  // 图表参数 - chart parameter var $param = array(); // 保存为文件的路径 - saving file directory var $savefile; // 图形参数 - graphics references var $graphics = array(); // 标题参数 - title references var $title = array(); // 注释参数 - description references var $desc = array(); // 图表颜色数组 - colors array in chart var $colors = array(); // 颜色定义 - define color var $colordefine = array(  "lightgray" => array(192, 192, 192), "darkgray" => array(144, 144, 144), "lightred" => array(255, 0, 0), "darkred" => array(128, 0, 0), "lightgreen" => array(0, 255, 0), "darkgreen" => array(0, 80, 0), "lightblue" => array(0, 0, 255), "darkblue" => array(0, 0, 80), "lightyellow" => array(255, 255, 0), "darkyellow" => array(200, 200, 50), "lightcyan" => array(0, 255, 255), "darkcyan" => array(0, 90, 90),                ); // ============================ 设置函数 - setting functions ============================ /* * @todo 设置图像背景色 - set the backgroundcolor of the chart image * * @param int $red * @param int $green * @param int $blue * */function setbgcolor($red = 0, $green = 0, $blue = 0) {  $this->bgcolor[0] = $red;  $this->bgcolor[1] = $green;  $this->bgcolor[2] = $blue; } /* * @todo 设置图像参数 - set the parameters of the chart image * * @param string $type * @param int $d3d * @param int $width * @param int $height * @param int $quality * @param array $data * @param string $savefile * */function setchartdata($type = "pie", $d3d = 1, $width = 400, $height = 400, $quality = 70, $data = array(), $savefile = '') {  $this->type = $type;     // 图表类型 - type of the chart : pie, column, line  $this->d3d = $d3d;     // 3D效果 -  $this->width = $width;     // 图表宽度  $this->height = $height;     // 图表高度  $this->quality = $quality;     // 图表显示质量  $this->param = $data;     // 源数据数组  $this->savefile = $savefile;     // 保存文件路径 } /* * @todo 设置图像标题 - set the title of the chart * * @param string $tstring * @param float $tfontsize * @param float $tangle * @param int $tposx * @param int $tposy * @param string $tfontfile * @param int $tfred * @param int $tfgreen * @param int $tfblue * */function settitle($tstring = '', $tfontsize = 20, $tangle = 0, $tposx = 10, $tposy = 20, $tfontfile = 'c:/windows/fonts/simhei.ttf', $tfred = 0, $tfgreen = 0, $tfblue = 0) {  $this->title = array($tfontsize, $tangle, $tposx, $tposy, $tfontfile, $tstring, $tfred, $tfgreen, $tfblue); } /* * @todo 设置图像注释 - set the decsription of the chart * * @param int $dposx * @param int $dposy * @param int $dwidth * @param int $dheight * @param int $dmargin * @param int $dsize * @param int $dangle * @param string $dfontfile * @param int $dfred * @param int $dfgreen * @param int $dfblue * */function setdesc($dposx = 0, $dposy = 0, $dwidth = 100, $dheight = 300, $dmargin = 10, $dsize = 10, $dangle = 0, $dfontfile = 'c:/windows/fonts/simhei.ttf', $dfred = 0, $dfgreen = 0, $dfblue = 0) {  $this->desc = array($dposx, $dposy, $dwidth, $dheight, $dmargin, $dsize, $dangle, $dfontfile, $dfred, $dfgreen, $dfblue); } /* * @todo 设置图形 - set the graphics of the chart * * @param int $gstartx * @param int $gstarty * @param int $gwidth * @param int $gheight * @param int $gmargin * @param float $shadow * */function setgraphics($gstartx = 0, $gstarty = 0, $gwidth = 100, $gheight = 100, $gmargin = 10, $shadow = 0.1) {  $this->graphics = array($gstartx, $gstarty, $gwidth, $gheight, $gmargin, $shadow); } // ============================ 生成函数 - build functions ============================ /* * @todo 生成图表实例 - build chart object * */ function buildchart()     {  // 图像头信息 - header of the image file  header("Content-type: image/jpeg");  // 建立图像 - create image  $this->chart = imagecreatetruecolor($this->width, $this->height);  // 填充背景色 - set backgroundcolor  $bgc = imagecolorallocate($this->chart, $this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]);         imagefill($this->chart, 0, 0, $bgc);  // 定义颜色 - allocate colors in the graphics  foreach($this->colordefine as $key => $value)      {            $$key = imagecolorallocate($this->chart, $value[0], $value[1], $value[2]);  array_push($this->colors, $$key);    // 颜色变量入栈 - add color variables into array      } } /* * @todo 生成图表标题 - build title of the chart * */ function buildtitle()     {  // 设置标题颜色 - set title color  $titlecolor = imagecolorallocate($this->chart, $this->title[6], $this->title[7], $this->title[8]);  // 写标题 - write title    imagettftext($this->chart, $this->title[0], $this->title[1], $this->title[2], $this->title[3], $titlecolor, $this->title[4], $this->title[5]); } /* * @todo 生成图表说明 - build description of the chart * */ function builddesc()     {  // 注释位置变量 - image position variables  $dposx = $this->desc[0];  $dposy = $this->desc[1];     // 注释起始坐标 - the start position of the description  $w = $this->desc[2];     // 注释部分宽度 - width of all description  $h = $this->desc[3];     // 注释部分高度 - height of all description  $num = count($this->param);     // 注释数量 - number of description lines  $perh = round($h / $num);      // 每行注释的平均高度 - height of each description line  $margin = $this->desc[4];     // 注释的间距 - margin between square and font  $dsize = $this->desc[5];     // 注释的字体大小 - font size of description  $dangle = $this->desc[6];     // 注释的字体角度 - font display angle of description  $dfontfile = $this->desc[7];     // 注释的字体文件 - font file of description  $dfcolor = imagecolorallocate($this->chart, $this->desc[8], $this->desc[9], $this->desc[10]);     // 注释的字体颜色 - font color of description    // 写注释 - write description  $dstring = array_keys($this->param);  for($i = 0; $i < $num; $i++)    {  // 矩形色块 - colorful square         imagefilledrectangle($this->chart, $dposx, $dposy, $dposx + $dsize, $dposy + $dsize, $this->colors[$i * 2]);  // 写文字 - write string      imagettftext($this->chart, $dsize, $dangle, $dposx + $dsize + $margin, $dposy + $dsize, $dfcolor, $dfontfile, $dstring[$i] . " - " . $this->param[$dstring[$i]]);  // 下移 - move down to write next description  $dposy += $perh;    }     } /* * @todo 生成图形 - build graphics of the chart * * @param source $chart * @param int $d3d * @param array $param * @param array $colordefine * */ function buildgraphics()     {  // 定义生成图形函数 - define make graphics function   // ==================== 饼状图 - pie ====================  if($this->type == "pie")   {    // 取得图形位置 - get the positoin of the graphics  $posx = $this->graphics[0];  $posy = $this->graphics[1];  // 取得图形宽度和高度 - get width and height of the graphics  $w = $this->graphics[2];  $h = $this->graphics[3];  // 图形边距 - graphics margin  $margin = $this->graphics[4];  // 3D阴影高度对于椭圆高度的比例 - percent of 3D effect shadow height as the height of the ellipse  $shadow = $this->graphics[5];  // 图形位置变量 - image position variables  $centerx = round($posx + $w / 2 + $margin);  $centery = round($posy + $h / 2 + $margin);     // 椭圆中心坐标 - the center of the ellipse           // 数据处理 - data process  $total = array_sum($this->param);     // 取得总数 - get total  $percent = array(0);     // 保存比例 - save each percent  $temp = 0;  foreach($this->param as $v)           {  $temp += 360 * ($v / $total);  array_push($percent, $temp);     // 保存角度 - save angle           }  // 生成饼状图 - make pie chart     // 生成3D饼状图 - make 3D pie chart  if($this->d3d == 1)               {  // 3D阴影 - make 3D shadow  for ($j = ($centery * (1 + $shadow)); $j > $centery; $j--)                    {  for ($k = 0; $k < count($percent)-1; $k++)                      {                        imagefilledarc($this->chart, $centerx, $j, $w, $h, $percent[$k], $percent[$k + 1], $this->colors[$k * 2 + 1], IMG_ARC_NOFILL);                }                     }              }  // 生成平面饼状图 - make 2D pie chart  for ($i = 0; $i < count($percent)-1; $i++)        {      imagefilledarc($this->chart, $centerx, $centery, $w, $h, $percent[$i], $percent[$i + 1], $this->colors[$i * 2], IMG_ARC_PIE);        }   }  // ==================== 柱状图 - column ====================  elseif($this->type == "column")   {  // 取得图形位置 - get the positoin of the graphics  $posx = $this->graphics[0];  $posy = $this->graphics[1];  // 取得图形宽度和高度 - get width and height of the graphics  $w = $this->graphics[2];  $h = $this->graphics[3];  // 图形边距 - graphics margin  $margin = $this->graphics[4];  // 3D阴影高度对于柱体宽度的比例 - percent of 3D effect shadow height as the width of the column  $shadow = $this->graphics[5];  // 图形位置变量 - image position variables  $startx = round($posx + $margin);  $starty = round($posy + $h - $margin);     // 图形左下角坐标 - the left-bottom position of the graphics           // 数据处理 - data process  $maxvalue = max($this->param);    // 取得最大值 - get max value  $num = count($this->param);     // 取得条柱个数 - get number of columns  $multiple = floor(log10($maxvalue));     // 取得数值区间 - get data field  $field = floor($maxvalue / pow(10, $multiple)) + 1;     // 区间数 - number of unit fields  $fieldnumber = $field > 5 ? $field : 5;     // 数据区域数量 - number of data fields  $topvalue = $field * pow(10, $multiple);     // 图表最高点数值 - value of the top  $unitx = ($w - $margin * 2) / $num;     // 取得x单位长度 - get x unit length  $unity = ($h - $margin * 2) / $fieldnumber;     // 取得y单位长度 - get y unit length  $shadowheight = $unitx / 2 * $shadow;     // 阴影宽度 - shadow height     // 初始化坐标系 - initialize reference frame  if($this->d3d == 1)     // 3D效果 - 3D effect     {            imagefilledpolygon($this->chart, array($startx, $starty, $startx + $shadowheight, $starty - $shadowheight, $startx + $shadowheight, $posy - $shadowheight, $startx, $posy), 4, $this->colors[0]);            imageline($this->chart, $startx + $shadowheight, $starty - $shadowheight, $startx + $shadowheight, $posy - $shadowheight, $this->colors[1]);           }     imageline($this->chart, $startx, $starty, $posx + $w, $starty, $this->colors[1]);     // x     imageline($this->chart, $startx, $starty, $startx, $posy, $this->colors[1]);     // y     // 区间标识 - declare fields  for($i = 0; $i <= $fieldnumber; $i++)         {  // 区间标识线 - lines declaring fields       // 3D效果 - 3D effect  if($this->d3d == 1)             {              imageline($this->chart, $startx, $starty - $unity * $i, $startx + $shadowheight, $starty - $unity * $i - $shadowheight, $this->colors[1]);        imageline($this->chart, $startx + $shadowheight, $starty - $unity * $i - $shadowheight, $posx + $w + $shadowheight, $starty - $unity * $i - $shadowheight, $this->colors[1]);       }  // 2D - 2D  else      {                    imageline($this->chart, $startx, $starty - $unity * $i, $posx + $w, $starty - $unity * $i, $this->colors[0]);             }  // 区间说明 - field description             imagettftext($this->chart, $this->desc[5], $this->desc[6], $posx, $starty - $unity * $i, $this->colors[0], $this->desc[7], $topvalue / $fieldnumber * $i);         }  // 生成条柱 - make columns  $paramkeys = array_keys($this->param);  for($j = 0; $j < $num; $j++)           {  $columnheight = ($h - $margin * 2) * ($this->param[$paramkeys[$j]] / $topvalue);     // 条柱高度 - column height  $columnx = $startx + $unitx / 4 + $unitx * $j;     // 条柱起点x坐标 - x coordinate of column               imagefilledrectangle($this->chart, $columnx, $starty - $columnheight, $columnx + $unitx / 2, $starty - 1, $this->colors[$j * 2]);     // 画条柱 - draw columns      // 3D效果 - 3D effect  if($this->d3d == 1)            {  // 轮廓线 - contour line                   imagerectangle($this->chart, $columnx, $starty - $columnheight, $columnx + $unitx / 2, $starty - 1, $this->colors[$j * 2 + 1]);  // 3D表面 - 3D top          imagefilledpolygon($this->chart, array($columnx, $starty - $columnheight, $columnx + $unitx / 2, $starty - $columnheight, $columnx + $unitx / 2 + $shadowheight, $starty - $columnheight - $shadowheight, $columnx + $shadowheight, $starty - $columnheight - $shadowheight), 4, $this->colors[$j * 2]);          imagepolygon($this->chart, array($columnx, $starty - $columnheight, $columnx + $unitx / 2, $starty - $columnheight, $columnx + $unitx / 2 + $shadowheight, $starty - $columnheight - $shadowheight, $columnx + $shadowheight, $starty - $columnheight - $shadowheight), 4, $this->colors[$j * 2 + 1]);  // 3D阴影 - 3D shadow          imagefilledpolygon($this->chart, array($columnx + $unitx / 2, $starty, $columnx + $unitx / 2 + $shadowheight, $starty - $shadowheight, $columnx + $unitx / 2 + $shadowheight, $starty - $columnheight - $shadowheight, $columnx + $unitx / 2, $starty - $columnheight), 4, $this->colors[$j * 2 + 1]);          imagepolygon($this->chart, array($columnx + $unitx / 2, $starty, $columnx + $unitx / 2 + $shadowheight, $starty - $shadowheight, $columnx + $unitx / 2 + $shadowheight, $starty - $columnheight - $shadowheight, $columnx + $unitx / 2, $starty - $columnheight), 4, $this->colors[$j * 2 + 1]);            }           }   }  // ==================== 曲线图 - line ====================  else  {  // 取得图形位置 - get the positoin of the graphics  $posx = $this->graphics[0];  $posy = $this->graphics[1];  // 取得图形宽度和高度 - get width and height of the graphics  $w = $this->graphics[2];  $h = $this->graphics[3];  // 图形边距 - graphics margin  $margin = $this->graphics[4];  // 每个点的直径 - diameter of each point  $pointsize = $this->graphics[5] * 20;  // 图形位置变量 - image position variables  $startx = round($posx + $margin);  $starty = round($posy + $h - $margin);     // 图形左下角坐标 - the left-bottom position of the graphics           // 数据处理 - data process  $maxvalue = max($this->param);    // 取得最大值 - get max value  $minvalue = min($this->param);    // 取得最小值 - get min value  $num = count($this->param);     // 取得点个数 - get number of points  $fieldnumber = $num;     // 数据区域数量 - number of data fields  $fielddata = $maxvalue - $minvalue;     // 取得数据区间 - get data field  $unitdata = $fielddata / $fieldnumber;     // 取得单位区间数值 - get unit field data value  $unitx = ($w - $margin * 2) / $num;     // 取得x单位长度 - get x unit length  $unity = ($h - $margin * 2) / $fieldnumber;     // 取得y单位长度 - get y unit length     // 初始化坐标系 - initialize reference frame     imageline($this->chart, $startx, $starty, $posx + $w, $starty, $this->colors[1]);     // x     imageline($this->chart, $startx, $starty, $startx, $posy, $this->colors[1]);     // y     // 区间标识 - declare fields  for($i = 0; $i <= $fieldnumber; $i++)         {  // 标识线 - declaring fields line       imageline($this->chart, $startx, $starty - $unity * $i, $posx + $w, $starty - $unity * $i, $this->colors[0]);        // 区间说明 - field description             imagettftext($this->chart, $this->desc[5], $this->desc[6], $posx, $starty - $unity * $i, $this->colors[0], $this->desc[7], $minvalue + $unitdata * $i);         }  // 生成线条 - make line  $paramkeys = array_keys($this->param);  $loca = array();     // 保存轨迹的数组 - array to save locas  for($i = 0; $i < $num; $i++)     // 得到轨迹数组 - get loca array           {  // 点x坐标 - x coordinate of the point  $pointx = $startx + $unitx * $i;  // 点y坐标 - y coordinate of the point  $pointy = $starty - $unity * $fieldnumber * (($this->param[$paramkeys[$i]] - $minvalue) / $fielddata);  // 坐标数据入栈 - push coordinates into array  $loca[$i * 2] = $pointx;  $loca[$i * 2 + 1] = $pointy;  // 画点 - draw point      imagefilledellipse($this->chart, $pointx, $pointy, $pointsize, $pointsize, $this->colors[$i * 2]);           }  $linecolor = imagecolorallocate($this->chart, $this->title[6], $this->title[7], $this->title[8]);     // 定义线条颜色 - define line color  for($i = 0; $i < $num + 3; )     {  // 画线条 - draw line      imageline($this->chart, $loca[$i], $loca[$i + 1], $loca[$i + 2], $loca[$i + 3], $linecolor);  $i += 2;     }   }     } /* * @todo 输出图像至浏览器或文件 - output the chart image to browser or file */ function outputchart() {  // 建立图标 - build chart  $this->buildchart();  // 写入图形 - build graphics  $this->buildgraphics();  // 写入注释 - build description  $this->builddesc();  // 写入标题 - build title  $this->buildtitle();  // 输出图像 - flush image         imagejpeg($this->chart, $this->savefile, $this->quality);         imagedestroy($this->chart);     } } ?>



*********************************************************************************

演示文件demo.php:
**********************************************************************************

<?php // 载入类文件 include('plchart.php'); //设置数据数组 $data = array("1月份:11%" => 20, "2月份:16%" => 23, "3月份:19%" => 27, "4月份:13%" => 18, "5月份:18%" => 24, "6月份:12%" => 25); // 实例化 $chart = new plchart(); // 设置背景色 // 三个参数为0-255 $chart->setbgcolor(255,255,255);     // 设置标题文字 $title = <<< string图表测试 TEST PIE CHART string; // 设置图表数据 /* * 第一个参数为图表类型,只能是三个值:pie, column, line * 第二个参数为是否启用3D显示,0代表不启用,1代表启动 * 第三个参数为图表的宽度 * 第四个参数为图表的高度 * 第五个参数为图表的图片质量,0-100,100为最佳质量,但文件相对也最大 * 第六个参数为原数据数组 */$chart->setchartdata("line", 0, 800, 600, 100, $data); // 设置标题 /* * 第一个参数为标题的字符串 * 第二个参数为标题字体大小 * 第三个参数为标题倾斜角度 * 第四个参数为标题位于图表的起始横坐标 * 第五个参数为标题文字的基准纵坐标 * 第六个参数为标题字体文件 * 最后三个参数为标题字体的RGB颜色 */$chart->settitle($title, 20, 0, 10, 20, 'c:/windows/fonts/simhei.ttf', 0, 0, 0); // 设置注释 /* * 第一个参数为注释位于图表的起始横坐标 * 第二个参数为注释位于图表的起始纵坐标 * 第三个参数为注释部分的宽度 * 第四个参数为注释部分的高度 * 第五个参数为注释内容与注释部分边框的间距 * 第六个参数为注释字体大小 * 第七个参数为注释字体倾斜角度 * 第六个参数为注释字体文件 * 最后三个参数为注释字体的RGB颜色 */$chart->setdesc(500, 100, 200, 300, 10, 18, 0, 'c:/windows/fonts/simhei.ttf', 0, 0, 0); // 设置图形 /* * 第一个参数为图形部分位于整个图表的左上角横坐标 * 第二个参数为图形部分位于整个图表的左上角纵坐标 * 第三个参数为图形部分的宽度 * 第四个参数为图形部分的高度 * 第五个参数为图形与图形部分边框的间距(纵坐标标记的宽度) * 第六个参数为3D阴影的相对比例或是轨迹图中圆点的直径 */$chart->setgraphics(10, 100, 500, 500, 50, 0.3); // 输出图表 $chart->outputchart();     // 销毁实例 unset($chart); ?>


성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
PHP와 Python : 다른 패러다임이 설명되었습니다PHP와 Python : 다른 패러다임이 설명되었습니다Apr 18, 2025 am 12:26 AM

PHP는 주로 절차 적 프로그래밍이지만 객체 지향 프로그래밍 (OOP)도 지원합니다. Python은 OOP, 기능 및 절차 프로그래밍을 포함한 다양한 패러다임을 지원합니다. PHP는 웹 개발에 적합하며 Python은 데이터 분석 및 기계 학습과 같은 다양한 응용 프로그램에 적합합니다.

PHP와 Python : 그들의 역사에 깊은 다이빙PHP와 Python : 그들의 역사에 깊은 다이빙Apr 18, 2025 am 12:25 AM

PHP는 1994 년에 시작되었으며 Rasmuslerdorf에 의해 개발되었습니다. 원래 웹 사이트 방문자를 추적하는 데 사용되었으며 점차 서버 측 스크립팅 언어로 진화했으며 웹 개발에 널리 사용되었습니다. Python은 1980 년대 후반 Guidovan Rossum에 의해 개발되었으며 1991 년에 처음 출시되었습니다. 코드 가독성과 단순성을 강조하며 과학 컴퓨팅, 데이터 분석 및 기타 분야에 적합합니다.

PHP와 Python 중에서 선택 : 가이드PHP와 Python 중에서 선택 : 가이드Apr 18, 2025 am 12:24 AM

PHP는 웹 개발 및 빠른 프로토 타이핑에 적합하며 Python은 데이터 과학 및 기계 학습에 적합합니다. 1.PHP는 간단한 구문과 함께 동적 웹 개발에 사용되며 빠른 개발에 적합합니다. 2. Python은 간결한 구문을 가지고 있으며 여러 분야에 적합하며 강력한 라이브러리 생태계가 있습니다.

PHP 및 프레임 워크 : 언어 현대화PHP 및 프레임 워크 : 언어 현대화Apr 18, 2025 am 12:14 AM

PHP는 현대화 프로세스에서 많은 웹 사이트 및 응용 프로그램을 지원하고 프레임 워크를 통해 개발 요구에 적응하기 때문에 여전히 중요합니다. 1.PHP7은 성능을 향상시키고 새로운 기능을 소개합니다. 2. Laravel, Symfony 및 Codeigniter와 같은 현대 프레임 워크는 개발을 단순화하고 코드 품질을 향상시킵니다. 3. 성능 최적화 및 모범 사례는 응용 프로그램 효율성을 더욱 향상시킵니다.

PHP의 영향 : 웹 개발 및 그 이상PHP의 영향 : 웹 개발 및 그 이상Apr 18, 2025 am 12:10 AM

phphassignificallyimpactedwebdevelopmentandextendsbeyondit

스칼라 유형, 반환 유형, 노조 유형 및 무효 유형을 포함한 PHP 유형의 힌트 작업은 어떻게 작동합니까?스칼라 유형, 반환 유형, 노조 유형 및 무효 유형을 포함한 PHP 유형의 힌트 작업은 어떻게 작동합니까?Apr 17, 2025 am 12:25 AM

PHP 유형은 코드 품질과 가독성을 향상시키기위한 프롬프트입니다. 1) 스칼라 유형 팁 : PHP7.0이므로 int, float 등과 같은 기능 매개 변수에 기본 데이터 유형을 지정할 수 있습니다. 2) 반환 유형 프롬프트 : 기능 반환 값 유형의 일관성을 확인하십시오. 3) Union 유형 프롬프트 : PHP8.0이므로 기능 매개 변수 또는 반환 값에 여러 유형을 지정할 수 있습니다. 4) Nullable 유형 프롬프트 : NULL 값을 포함하고 널 값을 반환 할 수있는 기능을 포함 할 수 있습니다.

PHP는 객체 클로닝 (클론 키워드) 및 __clone 마법 방법을 어떻게 처리합니까?PHP는 객체 클로닝 (클론 키워드) 및 __clone 마법 방법을 어떻게 처리합니까?Apr 17, 2025 am 12:24 AM

PHP에서는 클론 키워드를 사용하여 객체 사본을 만들고 \ _ \ _ Clone Magic 메소드를 통해 클로닝 동작을 사용자 정의하십시오. 1. 복제 키워드를 사용하여 얕은 사본을 만들어 객체의 속성을 복제하지만 객체의 속성은 아닙니다. 2. \ _ \ _ 클론 방법은 얕은 복사 문제를 피하기 위해 중첩 된 물체를 깊이 복사 할 수 있습니다. 3. 복제의 순환 참조 및 성능 문제를 피하고 클로닝 작업을 최적화하여 효율성을 향상시키기 위해주의를 기울이십시오.

PHP vs. Python : 사용 사례 및 응용 프로그램PHP vs. Python : 사용 사례 및 응용 프로그램Apr 17, 2025 am 12:23 AM

PHP는 웹 개발 및 컨텐츠 관리 시스템에 적합하며 Python은 데이터 과학, 기계 학습 및 자동화 스크립트에 적합합니다. 1.PHP는 빠르고 확장 가능한 웹 사이트 및 응용 프로그램을 구축하는 데 잘 작동하며 WordPress와 같은 CMS에서 일반적으로 사용됩니다. 2. Python은 Numpy 및 Tensorflow와 같은 풍부한 라이브러리를 통해 데이터 과학 및 기계 학습 분야에서 뛰어난 공연을했습니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

SecList

SecList

SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.