(PHP 4, PHP 5, PHP 7, PHP 8)
imagestring — Draw a string horizontally
Draws a string at the given coordinates.
imageОб'єкт GdImage, що повертається однією з функцій створення зображення, такою як imagecreatetruecolor().
fontМоже бути 1, 2, 3, 4, 5 для вбудованих шрифтів в кодуванні latin2 (де більші числа відповідають більшим шрифтам) або примірником класу GdFont, що повертається функцією imageloadfont().
xx-coordinate of the upper left corner.
yy-coordinate of the upper left corner.
stringThe string to be written.
colorІдентифікатор кольору, створений за допомогою imagecolorallocate().
| Версія | Опис |
|---|---|
| 8.1.0 |
Параметром font тепер може бути як і примірник
GdFont, так і int. Раніше допускався тільки
int.
|
| 8.0.0 |
Тепер image має бути примірником
GdImage. Раніше очікувався
gd-resource.
|
Приклад #1 imagestring() example
<?php
// Create a 100*30 image
$im = imagecreate(100, 30);
// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// Write the string at the top left
imagestring($im, 5, 0, 0, 'Hello world!', $textcolor);
// Output the image
header('Content-type: image/png');
imagepng($im);
?>Поданий вище приклад виведе щось схоже на: