小编use*_*085的帖子

将php字符串转换为图像

我想将 php 字符串转换为图像。我用这个代码

header("Content-type: image/png");
$string = '.the_title().';

$font  = 5;
$width  = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);

$image = imagecreatetruecolor ($width,$height);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);

imagestring ($image,$font,0,0,$string,$black);

imagepng ($image);
imagedestroy($image)    
Run Code Online (Sandbox Code Playgroud)

但它显示 the_title 作为文本而不是执行字符串

php string gd image

-2
推荐指数
1
解决办法
1万
查看次数

标签 统计

gd ×1

image ×1

php ×1

string ×1