简体   繁体   English

php在输出中没有给出任何错误

[英]php isn't giving any error in output

I have apache2 installed on my PC. 我的PC上安装了apache2。 And php5 and all the stuffs. 和php5和所有其他东西。 The php is also running fine. 的PHP也运行良好。 I checked commands INSERT INTO myTable etc and it's working fine. 我检查了命令INSERT INTO myTable等,它工作正常。 I've phpMyAdmin installed and it's also working fine. 我已经安装了phpMyAdmin,它也可以正常工作。 The problem is that I'm not getting any error when there is actually error. 问题是,当实际存在错误时,我没有收到任何错误。 for eg PHP : 对于例如PHP:

<?php
  <?php
  $umair = 1

  echo $umair;
  echo 'asdf';
?>

This code isn't outputting anything. 该代码不输出任何内容。 As you can see there is error of semicolon here and the PHP must show some error. 如您所见,此处存在分号错误,PHP必须显示一些错误。 And if I put the semicolon then the PHP runs as usual and get the output 1asdf 如果我使用分号,则PHP照常运行,并获得输出1asdf

Set your php.ini settings to display errors : 设置您的php.ini设置以显示错误:

- error_reporting to E_ALL
- display_errors to on

(those are developement environment settings of course ; more about error_reporting levels here ) (这些当然是开发环境设置; 有关error_reporting级别,请参见此处

You can find your php.ini location using phpinfo() in a PHP script. 您可以在PHP脚本中使用phpinfo()找到php.ini位置。

EDIT In case it isn't that, try to execute a valid script, and tell us if it runs correctly. 编辑如果不是那样,请尝试执行有效的脚本,并告诉我们脚本是否正确运行。 If it doesn't, it probably means that your php module installation failed somehow. 如果不是,则可能意味着您的php模块安装失败。

EDIT 2 Restarting Apache will be necessary after editing such parameters. 编辑2编辑此类参数后,必须重新启动Apache。

You can try to show the errors for the current file that you're working on right now by adding 您可以尝试通过添加来显示当前正在处理的当前文件的错误

error_reporting(E_ALL);

and try to check this 并尝试检查一下

The problem is that the missing ";" 问题在于缺少“;” is a parser error - and parsing is done before execution. 是解析器错误-解析是在执行之前完成的。 PHP will simply not even start executing an invalid script - so you don't see anything. PHP甚至根本不会开始执行无效的脚本-因此您什么也看不到。

Try to include this script in another script and run that - then you will get a clear error-msg! 尝试将此脚本包含在另一个脚本中并运行该脚本-然后您将得到一个明确的错误消息msg!

Here's more on that topic and also my script to do this: How to get useful error messages in PHP? 这里是关于该主题的更多信息,还有执行此操作的脚本: 如何在PHP中获取有用的错误消息?

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

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