Home > Backend Development > PHP Tutorial > 为什么打印异常的语句会把web的物理路径带出来

为什么打印异常的语句会把web的物理路径带出来

WBOY
Release: 2016-06-13 11:05:50
Original
801 people have browsed it

为什么打印错误的语句会把web的物理路径带出来?
有一个err.php 报如下错误:
Fatal error: Call to undefined function abc() in C:\apache\htdocs\test\err.php on line 3 


报的错误是对的,但是却把物理路径带出来了,不太安全,如何隐藏物理路径呢?
------解决方案--------------------
难道你想一直把错误展示给用户?
生产环境一般都是直接关掉错误提示。如果你执意想知道如何隐藏绝对路径,可以参看 set_error_handle(),这个函数会在出现错误时被调用。

set_error_handler(function(){<br />      $errinfo = func_get_args();<br />      $errinfo[2] = basename($errinfo[2]);<br />      echo "{$errinfo[1]} in {$errinfo[2]} on {$errinfo[3]}\n";<br />}); <br /><br />$d[hello] = 'helo';
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template