使用src加载php图像

wor*_*ion 0 php image

是否可以使用以下方式加载图像:

<img src="image.php?image_id=1">
Run Code Online (Sandbox Code Playgroud)

用于image.php:

$image_id = $_GET['image_id']; 
echo "image".$image_id.".png"; 
Run Code Online (Sandbox Code Playgroud)

Tuf*_*rım 5

你必须返回一个有效的图像,使用file_get_contentsreadfile获取图像的conent,然后输出到浏览器

 header("Content-Type:image/png");

    $image_id = $_GET['image_id']; 

    if(is_file($file = "image".$image_id.".png") ||  is_file($file = "no_image.png"))
        readfile($file); 
Run Code Online (Sandbox Code Playgroud)