Home > Backend Development > PHP Problem > How to solve php png garbled problem

How to solve php png garbled problem

藏色散人
Release: 2023-03-05 11:32:01
Original
2846 people have browsed it

Solution to php png garbled code: first find and open the PHP code file that caused the error; then delete all the html code, that is, the "html, head, body" code.

How to solve php png garbled problem

Recommendation: "PHP Video Tutorial"

Solution to garbled display of png images in php GD

Problem:

Code:

<?php
$im = imagecreate(100, 30);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
header("Content-type: image/png");
imagepng($im);
?>
Copy after login

Run result:

Fatal error: Call to undefined function imagecreate() in D:/wamp/www/index.php on line 2
Copy after login

Solution:

Put the html code (html , head, body), delete all these codes, and that’s it.

The above is the detailed content of How to solve php png garbled problem. 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