PHP中header('content-type:text/html;charset="utf-8')和error_reporting()的作用
1.header
PHP文件插入header("Content-type: text/html; charset=utf-8");
相当于页面里面的<meta http-equiv="Content-Type" content="text/html; charset=utf-8">;
目的:防止页面出现乱码
2.error_reporting
定义和用法:error_reporting()设置PHP的报错级别并返回当前级别。
函数语法:error_reporting(report_level)
如果参数 level 未指定,当前报错级别将被返回。下面几项是level可能的值:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
1:E_ERROR 致命的运行错误。错误无法恢复,暂停执行脚本。2:E_WARNING 运行时警告(非致命性错误)。非致命的运行错误,脚本执行不会停止。4:E_PARSE 编译时解析错误。解析错误只由分析器产生。8:E_NOTICE 运行时提醒(这些经常是你代码中的bug引起的,也可能是有意的行为造成的。)16:E_CORE_ERROR PHP启动时初始化过程中的致命错误。32:E_CORE_WARNING PHP启动时初始化过程中的警告(非致命性错)。64:E_COMPILE_ERROR 编译时致命性错。这就像由Zend脚本引擎生成了一个E_ERROR。128:E_COMPILE_WARNING 编译时警告(非致命性错)。这就像由Zend脚本引擎生成了一个E_WARNING警告。256:E_USER_ERROR 用户自定义的错误消息。这就像由使用PHP函数trigger_error(程序员设置E_ERROR)512:E_USER_WARNING 用户自定义的警告消息。这就像由使用PHP函数trigger_error(程序员设定的一个E_WARNING警告)1024:E_USER_NOTICE 用户自定义的提醒消息。这就像一个由使用PHP函数trigger_error(程序员一个E_NOTICE集)2048:E_STRICT 编码标准化警告。允许PHP建议如何修改代码以确保最佳的互操作性向前兼容性。4096:E_RECOVERABLE_ERROR 开捕致命错误。这就像一个E_ERROR,但可以通过用户定义的处理捕获(又见set_error_handler())8191:E_ALL 所有的错误和警告(不包括 E_STRICT) (E_STRICT will be part of E_ALL as of PHP 6.0) |
任意数目的以上选项都可以用“或”来连接(用 OR 或 |),这样可以报告所有需要的各级别错误。
例如,下面的代码关闭了用户自定义的错误和警告,执行了某些操作,然后恢复到原始的报错级别:
<?php
//禁用错误报告
error_reporting(0);
//报告运行时错误
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//报告所有错误
error_reporting(E_ALL);
?>
PHP中header('content-type:text/html;charset="utf-8')和error_reporting()的作用的更多相关文章
- {"timestamp":"2019-11-12T02:39:28.949+0000","status":415,"error":"Unsupported Media Type","message":"Content type 'text/plain;charset=UTF-8' not supported","path":&quo
在Jmeter运行http请求时报错: {"timestamp":"2019-11-12T02:39:28.949+0000","status&quo ...
- 遇到问题之“postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported”
postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported postman之所以报Uns ...
- Jmeter发送post请求报错Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
常识普及: Content-type,在Request Headers里面,告诉服务器,我们发送的请求信息格式,在JMeter中,信息头存储在信息头管理器中,所以在做接口测试的时候,我们维护Conte ...
- org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
最后找到我的问题,springmvc配置文件中没加 <mvc:annotation-driven/> java代码: @RequestMapping(value="/reques ...
- 接入WxPusher微信推送服务出现错误:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
背景 使用WxPusher微信推送服务 ,可以及时的将服务的一些运行异常信息,发送到自己的微信上,方便了解服务的运行状态(PS:这个服务是免费的). 你可以在这里看到WxPusher微信推送服务的接入 ...
- Content type 'application/json;charset=UTF-8' not supported异常的解决过程
首先说一下当时的场景,其实就是一个很简单的添加操作,后台传递的值是json格式的,如下图 ,后台对应的实体类, @Data @EqualsAndHashCode(callSuper = false) ...
- springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...
- ajax使用向Spring MVC发送JSON数据出现 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported错误
ajax使用向Spring MVC发送JSON数据时,后端Controller在接受JSON数据时报org.springframework.web.HttpMediaTypeNotSupportedE ...
- jmeter报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"的解决方法
1.报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supporte ...
- Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported告诉你,你的请求头是application/x- ...
随机推荐
- 替换linux系统文件etc下passwd文件的字段获取真正的root权限
sudo与root 很多人都知道使用linux可以利用sudo来执行一些root权限执行的事情,但是sudo和root还是有很大的区别的. 区别一:sudo可以执行的命令是root账户利用/etc/s ...
- Win8安装msi程序出现2502、2503错误解决方法
在Win8中,在安装msi安装包的时候常常会出现代码为2502.2503的错误.其实这种错误是由于安装权限不足造成的,因为这种msi的安装包不像其他exe的安装程序, 在安装包上点击"右键& ...
- 【CF883B】Berland Army 拓扑排序
[CF883B]Berland Army 题意:给出n个点,m条有向边,有的点的点权已知,其余的未知,点权都在1-k中.先希望你确定出所有点的点权,满足: 对于所有边a->b,a的点权>b ...
- jqueryui和easyui区别
jQuery自带的一个可选UI库,但是非常可惜,一些关键的组件没有包含进去,如TreeView, DataGrid,还需要寻找第三方的插件. EasyUI是某公司开发的一套对私免费,对公收费的UI库, ...
- PAT甲1077 Kuchiguse【字符串】【暴力】【Hash】【二分】
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...
- poj1850Code
Code Transmitting and memorizing information is a task that requires different coding systems for th ...
- htop详解
一.Htop的使用简介 大家可能对top监控软件比较熟悉,今天我为大家介绍另外一个监控软件Htop,姑且称之为top的增强版,相比top其有着很多自身的优势.如下: 两者相比起来,top比较繁琐 默认 ...
- linux、内核源码、内核编译与配置、内核模块开发、内核启动流程(转)
linux是如何组成的?答:linux是由用户空间和内核空间组成的为什么要划分用户空间和内核空间?答:有关CPU体系结构,各处理器可以有多种模式,而LInux这样的划分是考虑到系统的安全性,比如X86 ...
- 安装crf++的python包
在Linux上可以在taku910的github博客(https://taku910.github.io/crfpp/)下载crf++的linux版本,然后按照python文件夹下的README编译安 ...
- JS继承封装
<script> var extend = function (subClass, superClass) { //1.继承类的中间类 var Tmp = function() {}; / ...