0

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 パラメータ「名前」にあります。このテキストを画像の中央に配置する必要があります。

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

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

1 に答える 1

0

のような URL パラメータmypage.php?name=thename&submit=submitは必ずしも ~ の間name=にあるとは限りません|

PHP では、 を使用$_REQUESTして URL パラメーターの配列を取得できます。

于 2014-10-18T08:58:04.423 に答える