generate.php 正在工作,但是如果我尝试使用我的 index.php 检索图像,<img src="generate.php"/>
我会得到一个空白屏幕。
生成.php
<?php
header('Content-type: image/png');
if(isset($_GET['email'])){
$email = $_GET['email'];
}else{
$email = 'No email specified';
}
$email_length = strlen($email);
$font_size = 4;
$image_height = ImageFontHeight($font_size);
$image_width = ImageFontWidth($font_size) * $email_length;
$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$font_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, $font_size, 0, 0, $email, $font_color);
imagepng($image);
?>
索引.php
Name:<br>
Dave
<br><br>
Email: <br>
<img src="generate.php"/>