无需言 做自己 业 ,精于勤 荒于嬉.
- GD 和图像处理 函数 imagealphablending 设定图像的混色模式
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Create image$im = imagecreatetruecolor(100, 100); // Set alphablending to onimagealphablending($im, true); // Draw a squareimagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0)); // Outputheader('Content-type: image/png'); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imageaffinematrixconcat Concatenate two affine transformation matrices
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $m1 = imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' = 2, 'y' => 3)); $m2 = imageaffinematrixget(IMG_AFFINE_SCALE, array('x' = 4, 'y' => 5)); $matrix = imageaffinematrixconcat($m1, $m2); print_r($matrix); ?>
- GD 和图像处理 函数 getimagesize 取得图像大小
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php list($width, $height, $type, $attr) = getimagesize("img/flag.jpg"); echo "<img src=\"img/flag.jpg\" $attr>"; ?>
示例2
<?php $size = getimagesize("http://www.example.com/gifs/logo.gif"); // if the file name has space in it, encode it properly$size = getimagesize("http://www.example.com/gifs/lo%20go.gif"); ?>
示例3
<?php $size = getimagesize($filename); $fp=fopen($filename, "rb"); if ($size && $fp) { header("Content-type: { $size['mime']} "); fpassthru($fp); exit; } else { // error} ?>
示例4
<?php $size = getimagesize("testimg.jpg", &$info); if (isset($info["APP13"])) { $iptc = iptcparse($info["APP13"]); var_dump($iptc); } ?>
示例5
<?php $size = getimagesize($filename); $fp = fopen($filename, "rb"); if ($size && $fp) { header("Content-type: { $size['mime']} "); fpassthru($fp); exit; } else { // error} ?>
示例6
<?php list($width, $height, $type, $attr) = getimagesize("img/flag.jpg"); echo "<img src=\"img/flag.jpg\" $attr alt=\"getimagesize() example\" />"; ?>
示例7
<?php $size = getimagesize("http://www.example.com/gifs/logo.gif"); // if the file name has space in it, encode it properly$size = getimagesize("http://www.example.com/gifs/lo%20go.gif"); ?>
示例8
<?php $size = getimagesize("testimg.jpg", $info); if (isset($info["APP13"])) { $iptc = iptcparse($info["APP13"]); var_dump($iptc); } ?>
- GD 和图像处理 函数 imageantialias 是否使用抗锯齿(antialias)功能
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Setup an anti-aliased image and a normal image$aa = imagecreatetruecolor(400, 100); $normal = imagecreatetruecolor(200, 100); // Switch antialiasing on for one imageimageantialias($aa, true); // Allocate colors$red = imagecolorallocate($normal, 255, 0, 0); $red_aa = imagecolorallocate($aa, 255, 0, 0); // Draw two lines, one with AA enabledimageline($normal, 0, 0, 200, 100, $red); imageline($aa, 0, 0, 200, 100, $red_aa); // Merge the two images side by side for output (AA: left, Normal: Right)imagecopymerge($aa, $normal, 200, 0, 0, 0, 200, 100, 100); // Output imageheader('Content-type: image/png'); imagepng($aa); imagedestroy($aa); imagedestroy($normal); ?>
- GD 和图像处理 函数 imagebmp Output a BMP image to browser or file
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Create a blank image and add some text$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'BMP with PHP', $text_color); // Save the imageimagebmp($im, 'php.bmp'); // Free up memoryimagedestroy($im); ?>
- GD 和图像处理 函数 imagearc 画椭圆弧
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建一个 200X200 的图像$img = imagecreatetruecolor(200, 200); // 分配颜色$white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); // 画一个黑色的圆imagearc($img, 100, 100, 150, 150, 0, 360, $black); // 将图像输出到浏览器header("Content-type: image/png"); imagepng($img); // 释放内存imagedestroy($img); ?>
- GD 和图像处理 函数 imagechar 水平地画一个字符
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreate(100,100); $string = 'PHP'; $bg = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // prints a black "P" in the top left cornerimagechar($im, 1, 0, 0, $string, $black); header('Content-type: image/png'); imagepng($im); ?>
- GD 和图像处理 函数 imagecolorallocate 为一幅图像分配颜色
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreate('example.jpg', 100, 100); // 背景设为红色$background = imagecolorallocate($im, 255, 0, 0); // 设定一些颜色$white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // 十六进制方式$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $black = imagecolorallocate($im, 0x00, 0x00, 0x00); ?>
- GD 和图像处理 函数 imageaffinematrixget Get an affine transformation matrix
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $matrix = imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' => 2, 'y' => 3)); print_r($matrix); ?>
- GD 和图像处理 函数 imagecharup 垂直地画一个字符
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreate(100,100); $string = 'Note that the first letter is a N'; $bg = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // prints a black "Z" on a white backgroundimagecharup($im, 3, 10, 10, $string, $black); header('Content-type: image/png'); imagepng($im); ?>
- GD 和图像处理 函数 imagecolorallocatealpha 为一幅图像分配颜色 + alpha
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $size = 300; $image=imagecreatetruecolor($size, $size); // 用白色背景加黑色边框画个方框$back = imagecolorallocate($image, 255, 255, 255); $border = imagecolorallocate($image, 0, 0, 0); imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back); imagerectangle($image, 0, 0, $size - 1, $size - 1, $border); $yellow_x = 100; $yellow_y = 75; $red_x = 120; $red_y = 165; $blue_x = 187; $blue_y = 125; $radius = 150; // 用 alpha 值分配一些颜色$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75); $red = imagecolorallocatealpha($image, 255, 0, 0, 75); $blue = imagecolorallocatealpha($image, 0, 0, 255, 75); // 画三个交迭的圆imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow); imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red); imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue); // 不要忘记输出正确的 header!header('Content-type: image/png'); // 最后输出结果imagepng($image); imagedestroy($image); ?>
示例2
<?php $size = 300; $image=imagecreatetruecolor($size, $size); // something to get a white background with black border$back = imagecolorallocate($image, 255, 255, 255); $border = imagecolorallocate($image, 0, 0, 0); imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back); imagerectangle($image, 0, 0, $size - 1, $size - 1, $border); $yellow_x = 100; $yellow_y = 75; $red_x = 120; $red_y = 165; $blue_x = 187; $blue_y = 125; $radius = 150; // allocate colors with alpha values$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75); $red = imagecolorallocatealpha($image, 255, 0, 0, 75); $blue = imagecolorallocatealpha($image, 0, 0, 255, 75); // drawing 3 overlapped circleimagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow); imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red); imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue); // don't forget to output a correct header!header('Content-Type: image/png'); // and finally, output the resultimagepng($image); imagedestroy($image); ?>
- GD 和图像处理 函数 imagecolorclosest 取得与指定的颜色最接近的颜色的索引值
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
imagecolorclosest
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorclosest — 取得与指定的颜色最接近的颜色的索引值
说明
imagecolorclosest(
resource$image
,
int$red
,
int$green
,
int$blue
): int返回图像调色板中与指定的 RGB 值最“接近”的颜色。
指定的颜色与调色板中的每个颜色的“距离”的计算方法是把 RGB 值当成三维空间中点的坐标。
如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。
- GD 和图像处理 函数 gd_info 取得当前安装的 GD 库的信息
-
发表日期:2021-07-01 08:55:55 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php var_dump(gd_info()); ?>
- GD 和图像处理 函数 image_type_to_extension 取得图像类型的文件后缀
-
发表日期:2021-07-01 08:55:55 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建图像实例$im = imagecreatetruecolor(100, 100); // 保存图像imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG)); imagedestroy($im); ?>
- 多字节字符串 函数 mb_substitute_character 设置/获取替代字符
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php /* 设置为 Unicode U+3013 (GETA MARK) */ mb_substitute_character(0x3013); /* 设置十六进制格式 */ mb_substitute_character("long"); /* 显示当前设置 */ echo mb_substitute_character(); ?>
- 多字节字符串 函数 mb_strwidth 返回字符串的宽度
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_strwidth
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_strwidth — 返回字符串的宽度
说明
mb_strwidth(string$str
, string$encoding
= mb_internal_encoding()): int返回 string 类型
str
的宽度。多字节字符通常是单字节字符的两倍宽度。
字符宽度 字符 宽度 U+0000 - U+0019 0 U+0020 - U+1FFF 1 U+2000 - U+FF60 2 U+FF61 - U+FF9F 1 U+FFA0 - 2 参数
-
str
-
待解码的 string。
-
encoding
-
encoding
参数为字符编码。如果省略或是null
,则使用内部字符编码。
返回值
string
str
的宽度。 -
- 多字节字符串 函数 mb_substr_count 统计字符串出现的次数
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php echo mb_substr_count("This is a test", "is"); // 输出 2?>
- 多字节字符串 函数 mb_strtoupper 使字符串大写
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php $str = "Mary Had A Little Lamb and She LOVED It So"; $str = mb_strtoupper($str); echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO?>
示例2
<?php $str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός"; $str = mb_strtoupper($str, 'UTF-8'); echo $str; // 打印了 ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ?>
- 多字节字符串 函数 mb_strrchr 查找指定字符在另一个字符串中最后一次的出现
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_strrchr
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
mb_strrchr — 查找指定字符在另一个字符串中最后一次的出现
说明
mb_strrchr(
string$haystack
,
string$needle
,
bool$part
= false,
string$encoding
= mb_internal_encoding()
): stringmb_strrchr() 查找了
needle
在haystack
中最后一次出现的位置,并返回haystack
的部分。 如果没有找到needle
,它将返回false
。参数
-
haystack
-
在该字符串中查找
needle
最后出现的位置 -
needle
-
在
haystack
中查找这个字符串 -
part
-
决定这个函数返回
haystack
的哪一部分。 如果设置为true
,它将返回的字符是从haystack
的开始到needle
最后出现的位置。 如果设置为false
,它将返回的字符是从needle
最后出现的位置到haystack
的末尾。 -
encoding
-
使用的字符编码名称。如果省略了,则将使用内部编码。
返回值
返回
haystack
的一部分。 或者在没有找到needle
时返回false
。参见
- strrchr() - 查找指定字符在字符串中的最后一次出现
- mb_strstr() - 查找字符串在另一个字符串里的首次出现
- mb_strrichr() - 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现
-
- 多字节字符串 函数 mb_substr 获取部分字符串
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_substr
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_substr — 获取部分字符串
说明
mb_substr(
string$str
,
int$start
,
int$length
= NULL,
string$encoding
= mb_internal_encoding()
): string根据字符数执行一个多字节安全的 substr() 操作。 位置是从
str
的开始位置进行计数。 第一个字符的位置是 0。第二个字符的位置是 1,以此类推。参数
-
str
-
从该 string 中提取子字符串。
-
start
-
如果
start
不是负数,返回的字符串会从str
第start
的位置开始,从 0 开始计数。举个例子,字符串 'abcdef
',位置0
的字符是 'a
',位置2
的字符是 'c
',以此类推。如果
start
是负数,返回的字符串是从str
末尾处第start
个字符开始的。 -
length
-
str
中要使用的最大字符数。如果省略了此参数或者传入了NULL
,则会提取到字符串的尾部。 -
encoding
-
encoding
参数为字符编码。如果省略或是null
,则使用内部字符编码。
返回值
mb_substr() 函数根据
start
和length
参数返回str
中指定的部分。更新日志
版本 说明 5.4.8 length
传入NULL
,则从 start 提取到字符串的结尾处。 在之前的版本里,NULL
会被当作0
来处理。 -
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- 其他(0)