简体   繁体   English

PHP 错误未显示在浏览器中

[英]PHP Errors are not showing up in the browser

I am facing a strange problem.我面临一个奇怪的问题。 I have set up everything in php.ini file.我已经在 php.ini 文件中设置了所有内容。 But i can't get any errors showing up in the browser.但是我无法在浏览器中显示任何错误。 I googled to set up the.ini file and did all the required things.我用谷歌搜索设置了 .ini 文件并做了所有需要的事情。 But still i am not able to get error message displaying in the browser.但我仍然无法在浏览器中显示错误消息。 My PHP ini settings,我的 PHP ini 设置,

display_errors = On
display_startup_errors = On
error_reporting = E_ALL | E_STRICT
log_errors = On
track_errors = On

I tried with the following code to see error message,我尝试使用以下代码查看错误消息,

<?php
      require_once("sample.php");
 ?>

Actually the file sample is not available.实际上文件示例不可用。 So it must show Fatal error.所以它必须显示致命错误。 But it is showing a blank page.但它显示一个空白页。

Can you point me out to fix this?你能指出我来解决这个问题吗? I don't know what i am missing here.我不知道我在这里错过了什么。

You can also add custom error reporting to your php and test with that: 您还可以将自定义错误报告添加到您的PHP并测试:

<?php
    error_reporting( E_ALL );
    ini_set( "display_errors", 1 );
    require_once( "sample.php" );
?>

If you get fatals, then something is wrong with php.ini configuration ( maybe you have multiple php.ini files? ). 如果你发死了,那么php.ini配置有问题(也许你有多个php.ini文件?)。 If you still get nothing, then php can find the file ( maybe you have some redirects set up? Maybe some strange extensions? ) 如果你什么都没得到,那么php可以找到该文件(也许你有一些重定向设置?也许是一些奇怪的扩展?)

I found the problem. 我发现了这个问题。 Actually, PHP is installed with XDebug extension. 实际上,PHP安装了XDebug扩展。 So the problem is in that extension. 所以问题在于扩展。 Even i was not aware of that. 即使我没有意识到这一点。 Because this system was used by someone previously. 因为此系统以前曾被某人使用过。 I uninstalled and installed again with new supported version. 我使用新支持的版本重新安装并重新安装。 It works now. 它现在有效。 Thanks and sorry for the inconvenience friends. 感谢和抱歉给朋友带来的不便。

Try finding these words in your php.ini file 尝试在php.ini文件中找到这些单词

display_errors
error_reporting

change default value of display_errors from Off to On display_errors默认值从Off更改为On
change default value of error_reporting from XXXX to E_ERROR | E_PARSE error_reporting默认值从XXXX更改为E_ERROR | E_PARSE E_ERROR | E_PARSE

Restart apache server. 重启apache服务器。
Mind, It'll always show errors. 记住,它总会显示错误。

I know its an old thread, yet if someone is facing the same issue with php8 installation, use the following methods.我知道这是一个旧线程,但是如果有人在安装 php8 时遇到同样的问题,请使用以下方法。

    <?php

      phpinfo() 

    ?>` 

and you can find the location of php.ini in the phpinfo() page , php8 when i installed i had three directories inside /etc/php/ location 7.2, 8.0, 8.1.I was using ubuntu 18.04 .您可以在phpinfo() 页面中找到 php.ini 的位置,当我安装 php8 时,我在/etc/php/位置 7.2、8.0、8.1 中有三个目录。我使用的是ubuntu 18.04 Run this command to find php.ini location php -i |运行此命令找到 php.ini 位置php -i | grep "php.ini" .Try editing the php.ini in the shown location and if it does not work, follow phpinfo() page and find the php.ini location in the page. grep "php.ini" 。尝试在所示位置编辑 php.ini,如果不起作用,请按照 phpinfo() 页面并在页面中找到 php.ini 位置。

if you have added the following script如果您添加了以下脚本

       <?php

       error_reporting( E_ALL );
       ini_set( "display_errors", 1 );      
       require_once("sample.php");
      
       ?>

and you are able to see the error means something is overriding the php.ini.并且您可以看到错误意味着某些东西正在覆盖 php.ini。 Most likely in that case php.ini file location may be different.在这种情况下,很可能 php.ini 文件位置可能不同。 You might have edited the wrong php.ini file.I had to edit php.ini file in this location /etc/php/8.0/apache2 .您可能编辑了错误的 php.ini 文件。我不得不在此位置编辑 php.ini 文件/etc/php/8.0/apache2 Change display_errors directive to on in the php.ini file.在 php.ini 文件中将display_errors指令更改为on

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM