Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP imagettftext中心文本_Php_Imagettftext - Fatal编程技术网

PHP imagettftext中心文本

PHP imagettftext中心文本,php,imagettftext,Php,Imagettftext,我需要使用php中的imagepng和imagettftext函数将文本置于图像的中心 这是我的密码: include "config.php"; header('Content-type: image/png'); function between($src,$start,$end){ $txt=explode($start,$src); $txt2=explode($end,$txt[1]); return trim($txt2[0]); } $actual = "h

我需要使用php中的imagepng和imagettftext函数将文本置于图像的中心

这是我的密码:

include "config.php";
header('Content-type: image/png');
function between($src,$start,$end){
    $txt=explode($start,$src);
    $txt2=explode($end,$txt[1]);
    return trim($txt2[0]);
}
$actual = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

$background1 = "files/bg.png";
$background = imagecreatefrompng($background1);
//FONTS
$tahoma = "files/tahoma.ttf";
$bebas = "files/BebasNeue.otf";
$italic = "files/TahomaItalic.ttf";
$bold = "files/TahomaBold.ttf";a
//COLORS
$gray = imagecolorallocate($background, 76, 76, 76);
$dark_shadow = imagecolorallocate($background, 169, 181, 188);
//NAME
imagettftext($background, 32, 0, 181, 173, $gray, $bebas, urldecode(between($actual, "name=", "|")));
imagepng($background);
imagedestroy($background);
文本位于url参数“name”上。 我需要将此文本置于图像的中心

imagettftext($background, 32, 0, 181, 173, $gray, $bebas, urldecode(between($actual, "name=", "|")));

________________________________________
|                                      |
|                                      |
|               MY TEXT                |
|                                      |
|                                      |
|                                      |
|                                      |
|                                      |
---------------------------------------

mypage.php?name=thename&submit=submit
这样的URL参数不一定介于
name=
|


在PHP中,您可以使用
$\u REQUEST
获取URL参数数组。

您到底在问什么?@RobertVerkerk我需要在imagepng中使用imagettftext将文本居中。我的意思是,我的文本是一个水印,我需要使用php imagepng将其置于图像中心。