函数名:imagecharup()
适用版本:PHP 4, PHP 5, PHP 7
用法:该函数用于在图像上绘制一个垂直的字符。
语法:bool imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color )
参数:
返回值:成功时返回 true,失败时返回 false。
示例:
<?php
// 创建一个 200x100 的图像
$image = imagecreatetruecolor(200, 100);
// 设置背景颜色为白色
$bgColor = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $bgColor);
// 设置字体颜色为红色
$textColor = imagecolorallocate($image, 255, 0, 0);
// 在图像上绘制一个垂直的字符
imagecharup($image, 5, 50, 50, 'A', $textColor);
// 输出图像到浏览器
header('Content-Type: image/png');
imagepng($image);
// 释放图像资源
imagedestroy($image);
?>
以上示例创建了一个 200x100 的图像,将背景色设置为白色,字体颜色设置为红色,然后在图像上绘制了一个垂直的字符 "A",并将图像输出到浏览器。