dppx9253 2012-04-16 16:47
浏览 47
已采纳

页面内容在我的php GD绘图后没有显示

i tried to make a PHP GD banner like a plugin to make users copy and paste the image link and put in their websites, which worked ok so far for me, the problem is that when i load the image, other page content such as text , etc doesn't show into the browser

here is my php code to draw the image

<?php
    header("Content-type: image/png");
    $string = $_GET['text']. '  Click Here';
    $im     = imagecreatefrompng("../../images/banner.png");
    $orange = imagecolorallocate($im, 0, 0, 0);
    $px     = (imagesx($im) - 1.5 * strlen($string)) / 2;
    $font = 'verdana.ttf';
    imagestring($im,50, $px, 45, $string, $orange);
    imagepng($im);
    imagedestroy($im);
        ?>

hint: i put this code at the top of the page to make the header work

now other html code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add plugin</title>
</head>

<body>
<h3>Select One or More Plugin to connect your website for your reservation</h3>

<h4>Just A Button</h4>
<br />
<p>Instructions</p>
<p>Copy this code and paste into your website</p>

</body>
</html>

can someone suggest any solution to overcome this problem ?

  • 写回答

2条回答 默认 最新

  • dongyu1125 2012-04-16 17:03
    关注

    hint: i put this code at the top of the page to make the header work

    That's your problem. You've basically done the equivalent of opening an image file on your computer in a text editor and typing random characters at the end of the file. It'll break the image, and you'll never see the characters as they're meaningless within image data.

    Your PHP code can't return both image and HTML in one HTTP request. Instead, you can have two different PHP files, one for images, and one for HTML. Have the HTML include the image PHP via a standard <img src="image.php" alt="" /> tag.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了