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.
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); ?>
Run result:
Fatal error: Call to undefined function imagecreate() in D:/wamp/www/index.php on line 2
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!