Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP command line run does not show errors

Tags:

If I run this program on Centos as "php file.php" it shows no output but php -l shows it has errors(; after EOT missing). How do I enable error reporting in this case?

<?php  ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); $str = $_POST['name'];  file_put_contents("out.txt",$str);  print  <<<EOT <html><body><h1>You've entered $str</h1></body></html> EOT 

I've gone through: How can I get useful error messages in PHP?

like image 310
AgA Avatar asked Jun 11 '14 09:06

AgA


2 Answers

To override display_errors=Off in php.ini, add a -d flag to the command line:

php -d display_errors=on  script.php 

Or just edit the ini and turn the flag on.

like image 53
georg Avatar answered Sep 29 '22 13:09

georg


Try to set error_reporting to E_ALL instead of -1, this did the trick for me.

source: http://www.php.net/manual/en/function.error-reporting.php#85096

like image 20
Asko Avatar answered Sep 29 '22 14:09

Asko