Php错误的类别,主要有以下三大类:
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之路”

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Dreamweaver CS6
視覺化網頁開發工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器