php Cannot send session cache limiter - headers already sent 解决
这个问题主要体现在程序员没有一个良好的编码习惯,
解决办法:
<?php这个标识必须放到首行并且前面没有任何空格或bom编码。。。
然后开启session或者cookie才可以,
程序员要有良好的编码习惯,如何养成良好的习惯,请去学习python,格式不对,你连编译都通不过,呵呵
细节决定成败~~
送php验证码程序简单的转载别人的学习之用
image.php
<?php session_start(); for ($i = 0; $i < 4; $i++) //四位验证码 { @ $rand .= dechex(rand(1, 15)); //先生成随机数,再将十进制转十六进制,注意"." } $_SESSION['check_pic'] = $rand; $im = imagecreatetruecolor(100, 30); //创建图片 $bg = imagecolorallocate($im, 0, 0, 0); //设置颜色 $wh = imagecolorallocate($im, 255, 255, 255); imagestring($im, 5, 15, 8, $rand, $wh); //字体,1-6 header("Content-type: image/jpeg"); //输出图片 imagejpeg($im); ?>
image2.php
<?php session_start();//开启session echo " 验证码正确".$_SESSION['check_pic']; if(isset($_POST['check'])) { if($_POST['check']) { if($_POST['check']==$_SESSION['check_pic']) { echo " 验证码正确".$_SESSION['check_pic']; } else{ echo " 验证码错误".$_SESSION['check_pic']; } } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>image </title> <script type="text/javascript"> function test(){ alert(1); } </script> </head> <body> <FORM METHOD=POST ACTION=""> <img src="image.php"> <br> <!----链接图片---> <input type="text" name="check"><input type="submit" value="提交"> </FORM> </body> </html>
相关推荐
Noneyes 2020-11-10
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23