Php 在readfile()之后替换输出缓冲区
我必须在带有“image/jpeg”标题的文件中进行多次输出 我想显示的第一个文件是一个图像,然后我的脚本执行其他处理功能,最后我想在同一个循环中输出另一个图像 请参阅下面的代码:Php 在readfile()之后替换输出缓冲区,php,image,output,buffer,Php,Image,Output,Buffer,我必须在带有“image/jpeg”标题的文件中进行多次输出 我想显示的第一个文件是一个图像,然后我的脚本执行其他处理功能,最后我想在同一个循环中输出另一个图像 请参阅下面的代码: <?php header("content-type: image/jpeg"); readfile(realpath("mypath/default.jpg")); // this output my first image directly // many other functions echo $my
<?php
header("content-type: image/jpeg");
readfile(realpath("mypath/default.jpg")); // this output my first image directly
// many other functions
echo $myotherimage->getImageBlob(); // I want that the echo of this variable REPLACE the current outbut buffer ( the readfile )
?>
有什么办法可以做到这一点吗?
我试过使用ob_*PHP函数,但它不起作用。你不能这样做
当您将标题设置为内容类型时:image/jpeg
表示告诉浏览器
我将以流的形式向您发送图像数据
请注意,它是一个图像,而不是许多图像
如果要显示图像,应使用HTML
<img src="path/to/image-one"/>
<img src="path/to/image-two"/>