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

PHP实现圆角图片

工作中用到,自己写了一个,分享给有需要的人,前面是类定义,后面2行是调用。
优点:
不需要外部图片
支持PNG透明
可自定义圆角半径
不足:
只能指定一种透明色
 <?php
class RoundedCorner {
private $_r;
private $_g;
private $_b;
private $_image_path;
private $_radius;

function __construct($image_path, $radius, $r = 255, $g = 0, $b = 0) {
$this->_image_path = $image_path;
$this->_radius = $radius;
$this->_r = (int)$r;
$this->_g = (int)$g;
$this->_b = (int)$b;
}

private function _get_lt_rounder_corner() {
$radius = $this->_radius;
$img = imagecreatetruecolor($radius, $radius);
$bgcolor = imagecolorallocate($img, $this->_r, $this->_g, $this->_b);
$fgcolor = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bgcolor);
imagefilledarc($img, $radius, $radius, $radius*2, $radius*2, 180, 270, $fgcolor, IMG_ARC_PIE);
imagecolortransparent($img, $fgcolor);
return $img;
}

private function _load_source_image() {
$ext = substr($this->_image_path, strrpos($this->_image_path, '.'));
if (empty($ext)) {
return false;
}
switch(strtolower($ext)) {
case '.jpg':
$img = @imagecreatefromjpeg($this->_image_path);
break;
case '.gif':
$img = @imagecreatefromgif($this->_image_path);
break;
case '.png':
$img = @imagecreatefrompng($this->_image_path);
break;
default:
return false;
}
return $img;

}

public function round_it() {
// load the source image
$src_image = $this->_load_source_image();
if ($src_image === false) {
die('Sorry, can\'t load the image');
}
$image_width = imagesx($src_image);
$image_height = imagesy($src_image);

// create a new image, with src_width, src_height, and fill it with transparent color
$image = imagecreatetruecolor($image_width, $image_height);
$trans_color = imagecolorallocate($image, $this->_r, $this->_g, $this->_b


相关文档:

php+mysql中的一些语句

mysql建立一个表格:
create table hyhtbsc(
id int(4) primary key auto_increment,
username varchar(20),
password varchar(20)
);
查询数据库内容:
<?php
$conn = mysql_connect("localhost","root","pass");
mysql_select_db("mydb",$conn);
$sql = "select * from mytable";
$result = mysql_query($ ......

PHP编码规范

 
注:这是从PHPCMS开发文档里看到编码规范,虽名为PHPCMS的开发规范,但我觉得所有的PHP编程都该如此。写了那么多PHP,很多编码对照这规范都感觉欠缺很多,今后一定要对照纠正。
Phpcms 编码规范
1. 引言…. 2
2. 适用范围…. 2
3. 标准化的重要性和好处…. 3
4. PHP编码规范与原则…. ......

php字符串函数

 
1查找字符位置函数:
strpos($str,search,[int]):查找search在$str中的第一次位置从int开始;
stripos($str,search,[int]):函数返回字符串在另一个字符串中第一次出现的位置。该函数对大小写不敏感
strrpos($str,search,[int]):查找search在$str中的最后一次出现的位置从int
2、提取子字符函数(双字节)
subm ......

PHP面试题(附答案)

1.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在预定义变量(1)中;而链接到当前页面的的前一页面URL记录在预定义变量(2)中 
<?php
//本页地址,SCRIPT_NAME也可以
echo $_SERVER['PHP_SELF']."<br />";
//链接到当前页面的前一页面的 URL 地址:
echo $_SERVER ......

php防止页面刷新代码

 可用于php的计数器和表单的提交,防止反复刷新。
复制代码
<?php
session_start();
$allow_sep = "30000";
if (isset($_SESSION["post_sep"]))
{
if (time() - $_SESSION["post_sep"] < $allow_sep)
{
exit("请不要反复刷新");
}
else
{
$_SESSION["post_sep"] = time();
}
}
e ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号