易截截图软件、单文件、免安装、纯绿色、仅160KB

php绘制饼状图

drawPieImg()函数包含8个参数,$title为饼状图的标题;$dataArr为需要显示的数据数组;$labelArr为对应数据的标签分类数组;$colorArr为对应数据的绘图颜色数组,这4个参数是必须的,对于不同的系统应用传递相应的参数即可。接下来的4个参数,负责设置要生成的饼状图的大小,如果不设置则使用系统默认值。程序按照床底数组数据的大小,从0度开始绘制,方向按照顺时针方向依次绘制对应数据占据的扇面大小。
<?php
//变量定义,画椭圆弧时的角度大小
define("ANGLELENGTH",3);
/**
* 绘制图片
* @param $title 3D图的标题
* @param $dataArr 显示的数据数组
* @param $labelArr 对应数据的标签分类数组
* @param $colorArr 对应绘图颜色的数组
* @param $a 画布的基准宽度
* @param $b 画布的基准高度
* @param $v 3D柱的高度
* @param $font 字体大小
* @return 绘制成功的图片访问路径
*/
function drawPieImg($title, $dataArr, $labelArr, $colorArr, $a=250, $b=120, $v=20, $font=10){
$ox = 5+$a;
$oy = 5+$b;
$fw = imagefontwidth($font);
$fh = imagefontheight($font);
$n = count($dataArr);//计算数组长度
$w = 10+$a*2;
$h = 10+$b*2+$v+($fh+2)*$n;
//创建画板
$img = imagecreate($w, $h);
//转RGB为索引色
for($i=0; $i<$n; $i++)
$colorArr[$i] = drawIndexColor($img,$colorArr[$i]);//为图像$img分配颜色
$clrbk = imagecolorallocate($img, 0xff, 0xff, 0xff);
$clrt = imagecolorallocate($img, 0x00, 0x00, 0x00);
//填充背景色
imagefill($img, 0, 0, $clrbk);
//求和
$tot = 0;
for($i=0; $i<$n; $i++)
$tot += $dataArr[$i];
//每个分类的起始角度大小
$sd = 0;
//每个分类所占据的角度大小
$ed = 0;
$ly = 10+$b*2+$v;
for($i=0; $i<$n; $i++){
$sd = $ed;
$ed += $dataArr[$i]/$tot*360;
//画3d扇面
draw3DSector($img, $ox, $oy+20, $a, $b, $v, $sd, $ed, $colorArr[$i]);
//画标签
imagefilledrectangle($img, 5, $ly, 5+$fw, $ly+$fh, $colorArr[$i]);
imagerectangle($img, 5, $ly, 5+$fw, $ly+$fh, $clrt);
//中文转码
$str = iconv("GB2312", "UTF-8", $labelArr[$i]);
imagettftext($img, $font, 0, 5+2*$fw, $ly+13, $clr


相关文档:

php 目录和文件操作

<?php
//新建目录
mkdir("/path/to/my/dir", 0700); //0700表示权限最大
//删除目录
rmdir("/path/to/my/dir");
//遍历目录
$p =dir(/etc/php5);
echo "handler:".$p->handler;
while(false!=$entry=$p->read()){
    echo $entry."\n" ;
}
$p->close();
//输出文件内容
$handle=@ ......

HTTP Only cookies without PHP 5.2


HTTP Only cookies without PHP 5.2
by Matt Mecham
on September 12, 2006
For a while, Microsoft have had a flag
for cookies called ‘httponly’. This doesn’t sound particularly
exciting, but it is a vital step forward for web application security.
This flag tells Internet Expl ......

httpOnly cookie flag support in PHP 5.2

http://ilia.ws/archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html
Thanks to a patch from Scott
MacVicar that I've just applied to CVS, PHP 5.2 will have support for
httpOnly cookie flag. This neat little feature allows you to mark a
newly created cookie as HTTP only, another words inacce ......

PHP Session 两种不同存储方式

转自:http://www.cmsgp.org/article/3.html PHP Session使我们能够将用户的数据保存在服务器端。但是Session数据是临时的,并且通常当用户关闭浏览器时,保存Session id的Cookie就会被删除,相关的Session数据也将因此丢失。当然,我们可以通过修改session.cookie_lifetime这个参数来控制Cookie有效时间。
PHP Sessi ......

PHP正则表达式百科

基本概念
一个正则表达式通常被称为一个模式 (pattern),为用来描述或者匹配一系列符合某个句法规则的字符串。例如:Handel、Händel 和 Haendel 这三个字符串,都可以由“H(a|ä|ae)ndel”这个模式来描述。大部分正则表达式的形式都有如下的结构:
选择| 竖直分隔符代表选择。例如“gray|grey&rd ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号