PHP 中的 imagecharup() 函数
imagecharup() 函数用于竖直绘制字符。
语法
imagecharup( img, font, x, y, c, color )
参数
img:使用 imagecreatetruecolor() 创建图像
font:设置字体大小。对于 latin2 编码中的内置字体,可以为 1、2、3、4、5
x:x 坐标
y: y 坐标
c:需要绘制的字符
color:颜色标识符
返回值
imagecharup() 函数在成功时返回 TRUE,在失败时返回 FALSE。
示例
以下是一个示例
<?php
$img = imagecreate(300, 300);
$str = 'Demo';
$bg = imagecolorallocate($img, 190, 255, 255);
$color = imagecolorallocate($img, 120, 60, 100);
imagecharup($img, 5, 30, 50, $str, $color);
header('Content-type: image/png');
imagepng($img);
?>输出
以下为输出

示例
让我们看另一个示例
<?php
$img = imagecreate(270, 270);
$str = 'Example';
$bg = imagecolorallocate($img, 160, 185, 175);
$color = imagecolorallocate($img, 100, 120, 100);
imagecharup($img, 10, 80, 100, $str, $color);
header('Content-type: image/png');
imagepng($img);
?>输出
以下为绘制不同尺寸字符 E 的输出
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP