What to do if the php image cannot be displayed due to errors

藏色散人
Release: 2023-03-04 22:32:01
Original
2886 people have browsed it

The PHP image cannot be displayed due to errors because there is a notice error. The solution is: 1. Turn off the notice error prompt of wamp; 2. Define [$file=";] in the previous step.

What to do if the php image cannot be displayed due to errors

Recommended: "PHP Video Tutorial"

php image cannot be displayed due to an error

(The picture above shows the Firefox browser, and the Google browser displays a cross)

<?php
header("Content-type:image/jpeg");
 
$resource = fopen(&#39;001.png&#39;,&#39;r&#39;);
while($ff = fread($resource, 1024)){
    $file .= $ff;
};
echo $file;
Copy after login

Cause analysis: Because there is a notice error.

$file .= $ff;
Copy after login

The prototype is:

$file = $file.$ff;
Copy after login

The $file in the middle is not defined, and an error will be reported

Solution:

Option 1: Turn off the notice error prompt of wamp.

error_reporting(E_ALL & ~E_NOTICE);
Copy after login

Option 2: In Define $file=";

earlier

The above is the detailed content of What to do if the php image cannot be displayed due to errors. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!