首頁  >  文章  >  後端開發  >  为啥无法输出一张图片

为啥无法输出一张图片

WBOY
WBOY原創
2016-06-13 11:49:10922瀏覽

为什么无法输出一张图片

	session_start();<br />	<br />	//随机码的个数<br />	//$_rnd_code = 4;<br />	<br />	//创建随机码<br />	for($i=0;$i<4;$i++){<br />		$_nmsg.=dechex(mt_rand(0,15));<br />	}<br />	<br />	//保存session<br />	$_SESSION['code']=$_nmsg;<br />	<br />	//长和高<br />	$_width = 75;<br />	$_height = 25;<br />	<br />	//创建一张图像<br />	$_img = imagecreatetruecolor($_width,$_height);<br /><br />	<br /><br />	//输出图像<br />	header('Content-Type:image/png');<br />	imagepng($_img);

输出结果为
------解决方案--------------------
<br /><br /><b>Notice</b>:  Undefined variable: _rnd_code in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  Division by zero in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _heght in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  mt_rand(): max(0) is smaller than min(1) in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _rnd_code in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  Division by zero in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _heght in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  mt_rand(): max(0) is smaller than min(1) in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _rnd_code in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  Division by zero in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _heght in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  mt_rand(): max(0) is smaller than min(1) in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _rnd_code in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  Division by zero in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _heght in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  mt_rand(): max(0) is smaller than min(1) in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _rnd_code in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  Division by zero in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Notice</b>:  Undefined variable: _heght in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br /><br /><br /><b>Warning</b>:  mt_rand(): max(0) is smaller than min(1) in <b>D:\AMP\web\ide_tmp.php</b> on line <b>53</b><br /><br />‰PNG<br />
按错误信息修改
然后得:
仍然是不友好的“验证码”图片

------解决方案--------------------
将header注释掉,打开错误就可以看到错误。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn