PHP基础PHPGD库思路 建立画布 设置颜色 设置背景 作画(重要) 保存输出 移除画布 建立画布 只需设置宽和高 $img = imagecreatetruecolor(500,500); 设置颜色 imagecolorallocate(画布资源,R,G,B) $white = imagecolorallocate($img,255,255,255); $black = im作者王明昌发布时间2017-11-22文章目录思路建立画布设置颜色填充背景作图保存销毁思路建立画布设置颜色设置背景作画(重要)保存输出移除画布建立画布 只需设置宽和高 复制$img = imagecreatetruecolor(500,500); 设置颜色 imagecolorallocate(画布资源,R,G,B) 复制$white = imagecolorallocate($img,255,255,255); $black = imagecolorallocate($img,0,0,0); $red = imagecolorallocate($img,255,0,0); $blue = imagecolorallocate($img,0,0,255); $green = imagecolorallocate($img,0,255,0); 填充背景 imagefill(画布资源,0,0,填充的颜色); 复制imagefill($img,0,0,$black); 作图画点(imagesetpixel)复制imagesetpixel(画布资源,坐标x,坐标y,颜色); imagesetpixel($img,255,255,$white); 划线(imageline)复制imageline(画布资源,起点x,起点y,终点x,终点y,颜色); imageline($img,100,100,200,200,$white); 画矩形(imagerectangle)复制imagerectangle(画布资源,起点x,起点y,终点x,终点y,颜色); imagefilledrectangle(画布资源,起点x,起点y,终点x,终点y,颜色);//填充(filled) imagerectangle($img,100,100,400,400,$white); imagefilledrectangle($img,100,100,400,400,$white); 画多边形(imagepolygon)复制imagepolygon($img,array(各坐标),几边形,颜色); imagefilledpolygon($img,array(各坐标),几边形,颜色);//填充 imagepolygon($img,array(100,100,100,400,400,400),3,$white); imagefilledpolygon($img,array(100,100,100,400,400,400),3,$white); 画圆(imageellipse)复制imageellipse(画布资源,圆心x,圆心y,x长,y长,颜色); imagefilledellipse(画布资源,圆心x,圆心y,x长,y长,颜色);//填充 imageellipse($img,250,250,400,300,$white); imagefilledellipse($img,250,250,400,300,$white); 画弧线文本(imagettftext)复制imagettftext(画布资源,大小,弧度,开始x,开始y,颜色,字体,文本); imagettftext($img,30,45,100,200,$white,'./font/1.ttf','hahahhahaha'); 保存image/png image/gif image/jpeg 复制header("content-type:image/jpeg"); imagejpeg($img); 销毁复制imagedestroy($img);
2017-11-18PHP函数-数学函数abs 格式 描述 输入 输出 abs() 绝对值 整形/浮点型/字符串/进制数 与输入相对应 实例: $a = -12;//12 $a = -112.02;//11.02 $a = "-123.2"
2018-05-27获取上一级页面的url参考地址:http://www.qdxw.net/xwhtml/384.html 实战代码 从4.php 点击进入5.php 1.上一页地址: http://localhost/box/4.php 2
2017-11-19PHP函数why 提高开发效率 提高代码的重用性 有利于代码的维护 格式 function funName(形参,形参) { 代码块; return; } 函数名格式 函数名不区分大小写 函数名不能以数字开头,
2017-12-16转载 | PHP常用函数总结(180多个)数学函数 1.abs(): 求绝对值 $abs = abs(-4.2); //4.2 数字绝对值数字 2.ceil(): 进一法取整 echo ceil(9.999); // 10 浮点数进一取整 3
2017-11-19PHP基础语法php格式4种形式 1.1 标准式 1.2 短风格 1.3. asp风格 1.4 脚本风格 注: 1.2/1.3需要修改php.in文件 各改为short_open_tag = On asp_tags