Home >Backend Development >PHP Problem >php creates graphic garbled code

php creates graphic garbled code

藏色散人
藏色散人Original
2019-10-17 10:13:292322browse

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:

php creates graphic garbled code

Modified code:

<?php 
$im=imagecreate(200,200); //创建一个画布(单位像素pixel)
$white=imagecolorallocate($im,225,66,159); //设置画布的背景颜色为粉色 (256RGB)
header(&#39;content-type:image/gif&#39;);  //设置gif Image
imagegif($im); //输出gif图像
imagedestroy($im); 
?>

Running results:

php creates graphic garbled code

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!

Statement:
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