首页 / PHP / php错误调试_PHP教程
php错误调试_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php错误调试_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2222字,纯文字阅读大概需要4分钟。
内容图文
![php错误调试_PHP教程](/upload/InfoBanner/zyjiaocheng/176/333b6226ae2e474e91fb40245c350cd7.jpg)
1. 语法错误
程序这种情况通常在执行的时候,会显示错误信息(报错)。这种类型错误会阻止页面php脚本执行其他任务。如:
Echo 100.
Echo 100;
Echo 101;
?>
执行结果
Parse error: syntax error, unexpected ';' in…
2. 运行时错误
不会阻止php脚本的运行,但是会阻止该脚本做本身希望做的事情。如下:
echo “this is a demo”;
header('Location: http://www.example.com/');
//header()前不能有任何的输出 header() 必须在任何实际输出之前调用
?>
执行结果:
this is a demo
Warning: Cannot modify header information - headers already sent by (output started at E:\PhpProject1\test.php:7) in E:\PhpProject1\test.php on line 8
3. 程序逻辑错误
这种错误不但不会阻止php脚本的执行,也不会显示错误信息。一般用的调试程序手段是异常处理.如
$a=5;
If($a=6){
Echo $a;
}
?>
运行结果为6
报错级别:
错误 ERROR
页面脚本会停止运行
警告WARNING
页面脚本不会停止运行
通知NOTICE
页面脚本不会停止运行
/*
*ini_set()
*error_reporting()
*header()
*
*/
header(“Content-type:text/html;charset=utf-8”);
echo $a; //Notice: Undefined variable: a
echo "
+++++++++++++++++++++
";
echo "this is a Notice:Undefined variable";
echo “
”;
var_dump();
echo"
+++++++++++++++++++++
";
echo "This ia a Warning level Warning: Wrong parameter count for var_dump()...";
echo “
”;
ech “This is a demo”;
echo"
+++++++++++++++++++++
";
echo "This ia a Warning level Warning: Wrong parameter count for var_dump()...";
?>
ini_set()
Sets the value of a configuration option
string ini_set ( string $varname , string $newvalue )
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
为给出(指定)的配置选项赋值,在程序执行的过程中,配置选项将保持使用这个新赋给的值。当程序执行完成时,配置选项将恢复系统的默认值。
ini_set(‘display_errors’,1); 开启php.ini中的display_errors
error_reporting(E_ALL);
报错程序所有的错误、警告和注意。
error_reporting(E_ALL);
ini_set(‘display_errors’,1);
作者“我的PHP之路”
http://www.bkjia.com/PHPjc/478645.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478645.htmlTechArticlePhp错误的类别,主要有以下三大类: 1. 语法错误 程序这种情况通常在执行的时候,会显示错误信息(报错)。这种类型错误会阻止页面p...
内容总结
以上是互联网集市为您收集整理的php错误调试_PHP教程全部内容,希望文章能够帮你解决php错误调试_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。