Home >Backend Development >PHP Problem >php creates graphic garbled code
#php creates graphics garbled?
Problematic code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>php学习</title> </head> <body> <?php $im=imagecreate(200,200); //创建一个画布(单位像素pixel) $white=imagecolorallocate($im,225,66,159); //设置画布的背景颜色为粉色 (256RGB) imagegif($im); //输出gif图像 imagedestroy($im); ?> </body> </html>
Running result:
Modified code:
<?php $im=imagecreate(200,200); //创建一个画布(单位像素pixel) $white=imagecolorallocate($im,225,66,159); //设置画布的背景颜色为粉色 (256RGB) header('content-type:image/gif'); //设置gif Image imagegif($im); //输出gif图像 imagedestroy($im); ?>
Running results:
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of php creates graphic garbled code. For more information, please follow other related articles on the PHP Chinese website!