开发者

"PHP parse error" vs "Parse error" in OS X Server Terminal command

I am running a PHP script on a OS X 10.6 Server via Terminal like this:

cexa:~ soinro$ php /Volumes/dev1/cron/cron.php

And if the script has errors I get the output:

PHP Notice:  Use of undefined constant ccccc - assumed 'ccccc' in /Volumes/dev1/cron/cron.php on line 6
Notice: Use of undefined constant ccccc - assumed 'ccccc' in /Volumes/dev1/cron/cron.php on line 6
PHP Parse error:  syntax error, unexpected $end in /Volumes/dev1/http/~dev/_cron/cron.php on line 26
Parse error: syntax error, unexpected $end in /Volumes/dev1/http/~dev/_cron/cron.php on line 26

As you can see every notice / error is displayed twice: once as a "PHP Parse error" and once as a "Parse error".

The file I call is /Volumes/dev1/cron/cron.php. If this file has an error I only get the "Parse error", but if the files it requires have errors I get both the "PHP Parse error" and "Parse error" messages.

Why is this happening and how could I make it so that I get both messages (or just the ones without the "PHP Parse error") all the time;

For the discussion开发者_StackOverflow中文版's sake here is the original code I call:

ini_set('display_errors', 1);
$crons = array_merge(glob("/Volumes/dev1/http/*/_cron/*"), glob("/Volumes/dev1/http/~dev/*/_cron/*"));
foreach ($crons as $cron):
/* there is only one file in the array */
require_once $cron;
endforeach;
/* this is the endforeach I leave out when I want an error in this file */

and here is the file it require_once's

$mails = $db->result("select * from newsletter where status = 'sending'");
/* there are 3 elements in $mails */
foreach ($mails as $mail):
echo 'x';
endforeach;
/* this is the endforeach I leave out when I want an error in this file */

Thanks so much!!


What is happening is that you have both display_errors and log_errors enabled.

When log_errors is enabled, PHP writes errors in the file specified by the error_log ini setting (not to be confused with log_errors). If error_log is not set, the errors are wrote to stdout, that's why you are seeing them twice.

You have to either disable one of display_errors and log_errors; or to set error_log to some filename (or to syslog if you want to log to syslog).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜