php不显示错误

发布于 2024-07-30 18:30:21 字数 82 浏览 11 评论 0原文

我在 suse11.0 上的 php 中工作,我的问题是当我输入错误的语法或查询时,它不会显示错误,仅在这种情况下显示空白页面,

谢谢

im working in php on suse11.0 my problem is when i type a wrong syntax or query it doesnt show error only blank page shown at this situtaion

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

葬心 2024-08-06 18:30:21

您可以配置 error_reporting另请参阅),并启用错误显示(请参阅< a href="http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors" rel="noreferrer">display_errorsini_set) -- 至少在你的开发机器上

在你的 php.ini 文件中,你可以使用

error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On

或者,在你的 PHP 代码中:

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');

您可能还想在开发盒上安装Xdebug,以获得良好的stacktraces 发生错误/异常

当然,在您的生产机器上,您可能不希望显示错误; 因此必须根据您的环境进行配置;-)

You might to configure error_reporting (see also), and enable the displaying of errors (see display_errors or ini_set) -- at least on your development machine

In your php.ini file, you'd use

error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On

Or, in your PHP code :

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');

You might also want to install Xdebug on your development box, to get nice stacktraces wehn an error / exception occurs

Of course, on your production machine, you probably don't want to display errors ; so that will have to be configured depending on your environment ;-)

荭秂 2024-08-06 18:30:21

几乎可以肯定,display_errors 在 php.ini 中被禁用。

这对于产品服务器来说是一件好事,并且使得开发系统基本上无法使用。

对于开发系统,您可能需要将以下行之一添加到 php.ini 文件中:

error_reporting  =  E_ALL & ~E_NOTICE

error_reporting  =  E_ALL

It is almost certainly the case that display_errors is disabled in php.ini.

This is a good thing on product servers, and makes development systems basically unusable.

For a development system you probably want to add one of these lines to you php.ini file:

error_reporting  =  E_ALL & ~E_NOTICE

or

error_reporting  =  E_ALL
五里雾 2024-08-06 18:30:21

创建一个包含以下内容的文件,例如 test.php:

<?php
phpinfo();
?>

在浏览器中执行它并搜索 php.ini 文件所在的位置。
然后在 php.ini 中打开错误报告和显示错误。

Create a file for example test.php with this content:

<?php
phpinfo();
?>

Execute it in your browser and search where the php.ini file is located.
Than turn error reporting and displaying errors in php.ini on.

错々过的事 2024-08-06 18:30:21

确保 php.ini 中的 error_reporting 已打开

error_reporting  =  E_ALL | E_STRICT

Make sure error_reporting is turned on in php.ini

error_reporting  =  E_ALL | E_STRICT
波浪屿的海角声 2024-08-06 18:30:21

确保 php.ini 文件中的 display_errors 已打开并将 error_reporting 设置为 E_ALL。

Make sure in you php.ini file that display_errors is on and set error_reporting to E_ALL.

梅倚清风 2024-08-06 18:30:21

开始你的脚本:

<?php
    ini_set ('display_errors', 1);
    error_reporting (E_ALL | E_STRICT);
?>

Start your script with:

<?php
    ini_set ('display_errors', 1);
    error_reporting (E_ALL | E_STRICT);
?>
空心空情空意 2024-08-06 18:30:21

虽然其他答案确实回答了您的问题,但我只是想指出,最好提供您自己的错误检查例程(或代码),以便您的脚本向用户显示令人愉快的错误消息。
就像是

$result=@mysql_query($some_query);
if(!$result){
   if($debugging==TRUE){
       echo($some_query.'<br>'.mysql_error());//shows error in debugging mode
    }
   else{
     log_error()// error logging function
      die( 'there was a problem with your request the problem has been logged and we are working on it');//or something like that

   }
}
//no error
more code

While the other answers do answer your question, I just wanted to point out that it is best to provide your own error checking routine (or code) so that your script will show pleasant error messages to users.
something like

$result=@mysql_query($some_query);
if(!$result){
   if($debugging==TRUE){
       echo($some_query.'<br>'.mysql_error());//shows error in debugging mode
    }
   else{
     log_error()// error logging function
      die( 'there was a problem with your request the problem has been logged and we are working on it');//or something like that

   }
}
//no error
more code
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文