display_errors & error_reporting(php调试安全)
这两个选项对应的值即都可以在php.ini文件中设置,也都可以在php代码中使用相应的函数来设置。
在php.ini文件中的设置如下:
Display_errors = On : 打开错误回显。
Display_errors = Off:关闭错误回显。
Error_reporting = ,如下:
|
值 |
常量 |
描述 |
|
1 |
E_ERROR |
Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted |
|
2 |
E_WARNING |
Non-fatal run-time errors. Execution of the script is not halted |
|
4 |
E_PARSE |
Compile-time parse errors. Parse errors should only be generated by the parser |
|
8 |
E_NOTICE |
Run-time notices. The script found something that might be an error, but could also happen when running a script normally |
|
16 |
E_CORE_ERROR |
Fatal errors at PHP startup. This is like an E_ERROR in the PHP core |
|
32 |
E_CORE_WARNING |
Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core |
|
64 |
E_COMPILE_ERROR |
Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine |
|
128 |
E_COMPILE_WARNING |
Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine |
|
256 |
E_USER_ERROR |
Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error() |
|
512 |
E_USER_WARNING |
Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error() |
|
1024 |
E_USER_NOTICE |
User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error() |
|
2048 |
E_STRICT |
Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code |
|
4096 |
E_RECOVERABLE_ERROR |
Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler()) |
|
8191 |
E_ALL |
All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0) |
如有多个选项值,请使用 | 隔开。
在php代码中的设置如下:
Display_errors选项的设置使用ini_set函数。
Error_reporting选项的设置使用error_reporting函数。
代码如下:
例程1:
<?php
//获取并输出php.ini里display_errors变量的值
echo ini_get('display_errors');
echo '------------1-1-1------------';
echo '<br />';
//如果display_errors = 0(即Off),则重置display_errors = 1(即On)
if (!ini_get('display_errors'))
{
ini_set('display_errors', '1');
}
echo ini_get('display_errors');
echo '<br />';
//获取并输出php.ini里所有变量的值
$ini = ini_get_all();
print_r($ini);
?>
例程2:
<?php
//禁用错误报告
error_reporting(0);
//报告运行时错误
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//报告所有错误
error_reporting(E_ALL);
?>
例程3:
<?php
//记录生产环境错误日志
error_reporting(E_ALL);
ini_set('display_errors',0);
ini_set('log_errors',1);
ini_set('error_log','E:\'.date('Y-m-d').'_phpddt.com.txt');
?>
好了,php语言的安全特性到此就讲完了。
display_errors & error_reporting(php调试安全)的更多相关文章
- 高级php面试题(转)
一.mysql相关知识 1. mysql优化方式 MYSQL 优化常用方法 mysql 性能优化方案 2.如何分库分表 ...
- 高级php面试题
在网上看到一些高级php 的面试题目.. 最近接连面试了几家公司,有些重要问题记录一下,督促自己学习提高,同时希望给朋友们一些帮助.内容很多,一点点完善,一步步学习..有些是面试被问,有些是招聘要求, ...
- php常见的面试题目
一. 基本知识点1.1 HTTP协议中几个状态码的含义:503 500 401 403 404 200 301 302...200 : 请求成功,请求的数据随之返回.301 : 永久性重定向.302 ...
- 高级php面试题及部分答案
在网上看到一些高级php 的面试题目.. 闲来无事,搞了一些答案...可能不是很全面,留这以后备用吧. 一. 基本知识点1.1 HTTP协议中几个状态码的含义:503 500 401 403 404 ...
- PHP安全设置
1.register_globals(全局变量注册开关) 2.magic_quotes_gpc(魔术引号开关) 3.magic_quotes_runtime(魔术引号开关) 4.magic_quote ...
- PHP之提升代码质量36计
转载:https://www.binarytides.com/35-techniques-to-enhance-your-php-code/ 1.不要使用相对路径 常常会看到: require_onc ...
- LNMP(三)
第二十二次课 LNMP(三) 目录 一.Nginx负载均衡 二.ssl原理 三.生成ssl密钥对 四.Nginx配置ssl 五.php-fpm的pool 六.php-fpm慢执行日志 七.open_b ...
- php高级工程师面试题,行不行对照看下自己的实力
在网上看到一些高级php 的面试题目.. 最近接连面试了几家公司,有些重要问题记录一下,督促自己学习提高,同时希望给朋友们一些帮助.内容很多,一点点完善,一步步学习..有些是面试被问,有些是招聘要求, ...
- 高级php面试题转载
在网上看到一些高级php 的面试题目.. 最近接连面试了几家公司,有些重要问题记录一下,督促自己学习提高,同时希望给朋友们一些帮助.内容很多,一点点完善,一步步学习..有些是面试被问,有些是招聘要求, ...
随机推荐
- 两台CISCO2691测试静态路由汇总,浮动静态路由和负载分担静态路由配置
Dynagen的配置文件内容: #Lab - autostart = False [localhost] [[]] ram = image = C:\Program Files (x86)\Dynam ...
- HDU 3308 LCIS 线段树区间更新
最近开始线段树一段时间了,也发现了不少大牛的博客比如HH大牛 ,小媛姐.这个题目是我在看HH大牛的线段树专题是给出的习题,(可以去他博客找找,真心推荐)原本例题是POJ3667 Hotel 这个题目 ...
- Android 图片比较
Android中图片比较大致的流程如下: 将Drawable对象转化成Bitmap对象.(实际比较的是Bitmap对象,假设为B1和B2) 将B1和B2中的像素取出,分别放在2个数组中.(实际存储的是 ...
- Android如何在一个线性布局里完美显示两个listview啊?
复写一个listView ,在你布局文件中使用此view: <ScrollView android:layout_width="fill_parent" android:la ...
- C++中new和不new的区别
我们都知道C++中有三种创建对象的方法,如下: 复制代码代码如下: #include <iostream>using namespace std; class A{private: ...
- 【HDOJ】3061 Battle
Dinic解网络流模板题目.队列用STL就TLE... /* 3061 */ #include <iostream> #include <string> #include &l ...
- hadoop2.2编程:DFS API 操作
1. Reading data from a hadoop URL 说明:想要让java从hadoop的dfs里读取数据,则java 必须能够识别hadoop hdfs URL schema, 因此我 ...
- Is the Information Reliable?(差分约束)
Description The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years a ...
- ELK之nginx日志分析图表创建
一.kibana面板介绍 Discover:查询数据Visualize:统计图表Dashboard:显示面板,添加相应的图表在面板中Settings:创建索引 二.图表创建 1.饼图创建 以创建一个状 ...
- WPA Supplicant 用法
本文译至:https://wiki.archlinux.org/index.php/WPA_Supplicant_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29 ...