以前在wamp上学习php,但是现在改用apache+mysql+php的之后。。出现一些问题如,以前能编译通过,但是在后main这种环境侠,却出现未定义(undefine)错误提示一些编码正确,一部分乱码还有我写的如下程序:
global $numsg;
session_start();
for($i=0;$i<4;$i++){
$numsg .= dechex(mt_rand(0,15));}$_SESSION['code']=$numsg;
$width=200;
$height=200;$img=imagecreatetruecolor($width,$height);
Header("Content-type: image/png");
imagepng($img);
imagedestroy($img);输出不了图片。以前好像global $numsg;也不用定义为全局的另外问下集成环境和非集成环境那个好,为什么啊?
global $numsg;
session_start();
for($i=0;$i<4;$i++){
$numsg .= dechex(mt_rand(0,15));}$_SESSION['code']=$numsg;
$width=200;
$height=200;$img=imagecreatetruecolor($width,$height);
Header("Content-type: image/png");
imagepng($img);
imagedestroy($img);输出不了图片。以前好像global $numsg;也不用定义为全局的另外问下集成环境和非集成环境那个好,为什么啊?
在你的for循环之前写
$numsg = "";
以为你在for里面只写
$numsg .= dechex(mt_rand(0,15));
有连字符,在第一次循环的时候,会提示找不到这个$numsg变量的.