在一个php文件的开头 这样写
$code=$_POST["txtCode"];
$text=$_POST["txtText"];
$action=$_POST["hidAction"];
我的想法只是如果没有值提交过来 就这样放着就行了跑出来的结果是 报错如下Notice: Undefined index: txtCode in C:\Program Files\EasyPHP 3.0\www\test\ViewType.php on line 5Notice: Undefined index: txtText in C:\Program Files\EasyPHP 3.0\www\test\ViewType.php on line 6Notice: Undefined index: hidAction in C:\Program Files\EasyPHP 3.0\www\test\ViewType.php on line 7请问有办法让这个错误不报出来吗?因为程序完全可以正常运行的。

解决方案 »

  1.   


    这种不算是错误吧,只是一个警告。可以不理。1,可以将程序的错误级别来抑制输出:error_reporting(0);2,可以在程序里控制
    isset($_POST["txtCode"]) 来判断。
      

  2.   

    程序一开始加入下面这句:
    error_reporting(E_ALL ^ E_NOTICE);
    意识除了NOTICE消息,其它消息都要报告。
    或者则php.ini中修改error_reporting参数为E_ALL ^ E_NOTICE