[PHP错误异常]①--错误级别
2017-09-13 本文已影响7人
子木同





<?php
header("content-type:text/html;charset=utf-8;");
//$username='imooc'
//echo $username;
//deprecated级别的错误 最低级别的
if (ereg('imooc', 'this is imooc show time', $matches)) {
print_r($matches);
} else {
echo 'nothing find';
}
echo "<hr/>";
echo mysql_escape_string('\' or 1=1 #');
echo "<hr/>";
//Notice级别的错误
echo $king;
echo "<hr/>";
$userInfo = array('usernane' => "king", 'age' => 12);
echo $userInfo['username'];
echo "<hr/>";
echo $userInfo[age];// undefined constant age
echo '<hr/>';
//Warning级别的错误
settype($var, 'int');
var_dump($var);//int 0
echo "<hr/>";
settype($var, 'king');//Warning
echo "<hr/>";
var_dump($var);//int 0 不改变
echo "<hr/>";
//Parse error 语法解析错误
//echo "this is a test"
////Fatal error 不会向下执行
echo md6("king");
echo "程序继续向下执行";
?>
