【发布时间】:2013-01-14 23:42:06
【问题描述】:
我正在使用 调用一个 php 页面,该页面在显示实际的 gif 图像之前将一些内容写入数据库。我们称之为 VERSION 1
在任何给定页面上,代码如下所示:
<a href="http://www.abc.com">
<img alt="Hi" src="http://www.abc.com/logo.php"/></a>
那么,logo.php 看起来像这样:
// first update a database table with some relevant info
// then, output the logo image
header("Content-Type: image/gif");
echo file_get_contents("/path/to/image/logo.gif");
效果很好,(感谢我在这里收到的答案:Stack Question Answered
现在,我正在尝试创建第二个选项,它执行完全相同的操作,只是它显示一些 html 以及图像。我们称之为版本 2
在任何给定页面上,代码如下所示:
<a href="http://www.abc.com">
<img alt="Hi" src="http://www.abc.com/logo_html.php"/></a>
我希望另一个文件“logo_html.php”输出类似这样的内容
<p>Hello World</p>
<p>Some More html</p>
<img alt="Hi" src="http://www.abc.com/logo.gif"/>
我尝试使用简单的
Hello World
将“echo file_get_contents”文件更改为 php 文件,但没有显示任何内容(只是浏览器找不到图像时得到的 X .如果这是我的“logo_html.php”文件,我将其更改为这个,然后在 myfile.php 中放入一些文本,我也没有得到任何结果。
header("Content-Type: image/gif");
echo file_get_contents("/path/to/file/myfile.php");
我需要在我的 logo_html.php 文件中进行哪些更改才能调出和显示图像以及一些额外的 html?
一如既往地提前致谢!
【问题讨论】:
-
"logo_html.php" 只能有abc.com/logo.gif