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 的面试题目.. 最近接连面试了几家公司,有些重要问题记录一下,督促自己学习提高,同时希望给朋友们一些帮助.内容很多,一点点完善,一步步学习..有些是面试被问,有些是招聘要求, ...
随机推荐
- SQLMAP系列教程
1.SQLMAP安装及access注入: http://www.stronkin.com/en/CompHonorBig.asp?id=7 2.Mysql数据库注入 http://www.slib ...
- java向文件写数据的3种方式
下边列举出了三种向文件中写入数据的方式,当然还有其他方式,帮助自己理解文件写入类的继承关系.类的关系: file->fileoutputstream->outputstreamWriter ...
- C++内存管理(超长,例子很详细,排版很好)
[导语] 内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中获得了更好的性能,更大的自由,C++菜鸟的收获则是一遍一遍的检查代码和对C++的痛恨,但内存管理在C++中无处不 ...
- 启动redis出现Creating Server TCP listening socket *:6379: bind: No such file or directory
E:\redis>redis-server.exe redis.windows.conf [8564] 10 Oct 20:00:36.745 # Creating Server TCP lis ...
- CF 370
A:http://codeforces.com/problemset/problem/370/A #include<stdio.h> #include<string.h> #i ...
- ♫【CSS】命名颜色
color: aqua; 每个浏览器都支持一套它能识别且能正确渲染的命名颜色.这些颜色包括: aqua 浅绿色 #00ffffblack 黑色 #000000blue 蓝色 #0000fffuchsi ...
- 【session】
users.json { "tobi": { "password": "ferret", "name": "T ...
- [C# 网络编程系列]专题六:UDP编程
转自:http://www.cnblogs.com/zhili/archive/2012/09/01/2659167.html 引用: 前一个专题简单介绍了TCP编程的一些知识,UDP与TCP地位相当 ...
- (转载)在mysql中,column 'id' in field list is ambiguous
(转载)http://blog.chinaunix.net/uid-20665047-id-3137284.html column 'id' in field list is ambiguous 这个 ...
- linux 下的sublime
Sublime Text 2 的安装 : 在官方网站下载Linux版本 Or 执行 # wget http://c758482.r82.cf2.rackcdn.com/Sublime%20Tex ...