Rumah  >  Artikel  >  pembangunan bahagian belakang  >  为啥无法输出一张图片

为啥无法输出一张图片

WBOY
WBOYasal
2016-06-13 11:49:10922semak imbas

为什么无法输出一张图片

	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注释掉,打开错误就可以看到错误。

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn