以下是一个简单的PHP实例,展示如何使用PHP和GD库来生成海报。我们将创建一个基本的海报,包含文本和图像。
```php

// 设置内容类型
header('Content-Type: image/png');
// 创建一个画布
$width = 500;
$height = 300;
$image = imagecreatetruecolor($width, $height);
// 分配颜色
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
// 填充背景颜色
imagefill($image, 0, 0, $background_color);
// 添加文字
$text = "







