I’m using < img src=”logo.php” > to call a php page that writes some stuff to the database before displaying the actual gif image. Let’s call this VERSION 1
On any given page, the code looks like this:
<a href="http://www.abc.com">
<img alt="Hi" src="http://www.abc.com/logo.php"/></a>
Then, logo.php looks like this:
// 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");
It’s working great, (thanks to the answers i rec’d here: Stack Question Answered
Now, I’m trying to create a second option that does the exact same thing, except it displays some html as well as the image. Let’s call this VERSION 2
On any given page, the code looks like this:
<a href="http://www.abc.com">
<img alt="Hi" src="http://www.abc.com/logo_html.php"/></a>
I want this other file, “logo_html.php” to output something like this
<p>Hello World</p>
<p>Some More html</p>
<img alt="Hi" src="http://www.abc.com/logo.gif"/>
I tried to change the ‘echo file_get_contents’ file to a php file with a simple < p>Hello World< /p>, but nothing shows up (just the X that you get when the browser can’t find the image.
If this is my “logo_html.php” file, and I change it to this, then put some text in myfile.php, I also get no results.
header("Content-Type: image/gif");
echo file_get_contents("/path/to/file/myfile.php");
What do I need to change in my logo_html.php file to be able to bring up and display the image, plus some additional html?
Thanks in advance as always!
You cannot output anything but the image binary contents.
srcattribute of the image tag accepts the address to the binary image contents, not to the html.So the final answer: you cannot do that.