如何在 PHP 中的图像中写入阿拉伯文文本
我尝试用 PHP 在图像中写入阿拉伯文本。 这是我的代码:
<?php
header("Content-Type: image/png; charset=utf8");
$im = imagecreatetruecolor(150, 30);
// Create some colors
$white = imagecolorallocate($im, 100, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$font = 'tahoma.ttf';
$t = strrev('إن الدين عند الله الإسلام');
$text=utf8_encode($t);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
谢谢。
I tried to write an Arabic text in an image with PHP.
This is my code:
<?php
header("Content-Type: image/png; charset=utf8");
$im = imagecreatetruecolor(150, 30);
// Create some colors
$white = imagecolorallocate($im, 100, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
$font = 'tahoma.ttf';
$t = strrev('إن الدين عند الله الإسلام');
$text=utf8_encode($t);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对你有用:
fagd.php 代码在这里:
http://cdn.shirazitco.ir/fagd.txt
This will work for you:
fagd.php codes are here:
http://cdn.shirazitco.ir/fagd.txt
输出是什么?
strrev 函数与 unicode 不兼容
https://www.php.net/manual/en/function.strrev。 php
有关 unicode 兼容示例,请参阅那里的注释。
另请参阅 imagettftext 页面,
我认为以下评论正是您所需要的:
https://www.php.net/manual/en/function。 imagettftext.php#97767
What’s the output?
The strrev function is not unicode compatible
https://www.php.net/manual/en/function.strrev.php
See the comments there for examples of unicode compatible ones.
Also see the imagettftext page,
I think the following comment is exactly what you need:
https://www.php.net/manual/en/function.imagettftext.php#97767