开发者

Display php errors on osx

I'm trying to get PHP to display errors with syntax etc, during development in OSX.

I have edited my php.ini as follows;

display_errors = On
error_reporting = E_ALL开发者_运维百科

However, I still can't get the errors to display. I'm just stuck with a blank page. This happens even with the simplest of pages;

<?php

echo "ook"

?>

This should throw an error.

I would be grateful if anyone has any ideas on how to resolve this? I have definitely edited the correct php.ini, because a phpinfo file tells me so.


I would also like to state that the PHP end-tag (?>) is considered to be an explicit semi-colon (;)...

The following script is valid:

<?php
echo "Hello";
echo "There"
?>

While the following is not:

<?php
echo "Hello";
echo "There"


If the syntax of the script is not valid, you might get a white screen of death instead of an error. When you're testing error reporting, try a different error like dividing by zero.

Your php.ini line should read error_reporting = E_ALL, by the way. display_errors should equal 0 or 1.

Edit: Oops! Corrected factual error.


So I figured out what the problem was. My phpinfo file was telling me that I was using php.ini so of course I had been editing that. What I have discovered was that there was also a php.ini.default file in the same folder. I have deleted this file and now errors are showing. :)


I had a quite stupid problem which maybe someone else could also run into. In my php.ini I wrote accidentally:

error_reporting = E_ALL & E_STRICT

instead of:

error_reporting = E_ALL | E_STRICT

Which was filtering all the error messages. Took me a couple of minutes to find that stupid mistake. Hope I can save someone else's time ;).


There is no requirement for semi-colon(;) for last line in PHP, it not an error, like following code has no error due to missing semi-colon:

<?php echo 'test' ?>

Or

<?=$x ?>

Or

<?php 

echo "test code"
?>

Or

<?php 

echo "Test Code"  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜