# Internal server error on PHP syntax error?

- Thread: https://externals.io/message/57829
- Original archive: https://news-web.php.net/php.internals/57829
- Started by Jakov Sosic on 2012-02-13T16:50:28+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #57829 — Jakov Sosic — 2012-02-13T16:50:28+00:00

URL: https://externals.io/message/57829#57829

Hi.

I don't know if this is the right group to ask this kind of question, 
but if it isn't please excuse my french ;)

As far as I can see, PHP does not report back to Apache error 500 in 
case of a syntax error in code but displays empty page. For example this 
code:

<?php foobar();

always returns empty page.

I was curious, so I googled little around and found this old entry from 
this mailing list:

http://marc.info/?l=php-internals&m=124043575308005


So if that's true, and if I understand it correctly, there is no way for 
Apache to display error 500 in case of PHP syntax error?



-- 
Jakov Sosic
www.srce.unizg.hr

---

## #57830 — Ferenc Kovacs — 2012-02-13T16:55:19+00:00

URL: https://externals.io/message/57829#57830 · In reply to: #57829

> Hi.
>
> I don't know if this is the right group to ask this kind of question, but
> if it isn't please excuse my french ;)
>
> As far as I can see, PHP does not report back to Apache error 500 in case
> of a syntax error in code but displays empty page. For example this code:
>
> <?php foobar();
>
> always returns empty page.
>
> I was curious, so I googled little around and found this old entry from
> this mailing list:
>
> http://marc.info/?l=php-**internals&m=124043575308005<http://marc.info/?l=php-internals&m=124043575308005>
>
>
> So if that's true, and if I understand it correctly, there is no way for
> Apache to display error 500 in case of PHP syntax error?
>
>
It is implemented already, php will report HTTP 500 on fatal errors, except
if the headers were already sent.
And I also remember a php/xdebug bug, which caused the headers to be sent
see http://bugs.xdebug.org/view.php?id=587 and
https://bugs.php.net/bug.php?id=50921
Derick fixed it in 5.4
So I would suggest you to double-check that you aren't using xdebug when
you experience the problem, and that you don't send out the headers before
your code blows up.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #57831 — Jakov Sosic — 2012-02-13T17:08:17+00:00

URL: https://externals.io/message/57829#57831 · In reply to: #57830

> It is implemented already, php will report HTTP 500 on fatal errors, except
> if the headers were already sent.
> And I also remember a php/xdebug bug, which caused the headers to be sent
> see http://bugs.xdebug.org/view.php?id=587 and
> https://bugs.php.net/bug.php?id=50921
> Derick fixed it in 5.4
> So I would suggest you to double-check that you aren't using xdebug when
> you experience the problem, and that you don't send out the headers before
> your code blows up.

I know about xdebug bug, and xdebug is not even installed. I have same 
issue on CentOS v5 with original 5.1 RPMs, v5.2.17 from Atomic, v php53 
5.3.3 from CentOS 5.7, and finally on Debian with php v5.2.6.

I've tried this code:

<?php
ini_set('display_errors', 0);
$x = y();
?>

and I get this in logs:
IPADDR - - [13/Feb/2012:18:03:52 +0100] "GET /~username/test/ HTTP/1.1" 
500 20 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20100101 
Firefox/10.0.1"

so, 500 headers are returned but internal server error page is not 
displayed. All I get is a blank page.

So apache directive "ErrorDocument 500 /500.html" is useless in this case.


-- 
Jakov Sosic
www.srce.unizg.hr

---

## #57832 — Reindl Harald — 2012-02-13T17:10:55+00:00

URL: https://externals.io/message/57829#57832 · In reply to: #57831

Am 13.02.2012 18:08, schrieb Jakov Sosic:
> and I get this in logs:
> IPADDR - - [13/Feb/2012:18:03:52 +0100] "GET /~username/test/ HTTP/1.1" 500 20 "-" "Mozilla/5.0 (X11; Linux x86_64;
> rv:10.0.1) Gecko/20100101 Firefox/10.0.1"
> 
> so, 500 headers are returned but internal server error page is not displayed. All I get is a blank page.
> So apache directive "ErrorDocument 500 /500.html" is useless in this case.

yes, but the more important is the status code so that search
engines do not index you broken page, apache SHOULD NOT provide
his own error-page because you can also send 500 status code
within your script for whatever reason and want your output
not supressed in such cases

---

## #57836 — Jakov Sosic — 2012-02-13T21:11:50+00:00

URL: https://externals.io/message/57829#57836 · In reply to: #57832

> yes, but the more important is the status code so that search
> engines do not index you broken page, apache SHOULD NOT provide
> his own error-page because you can also send 500 status code
> within your script for whatever reason and want your output
> not supressed in such cases

OK but I would like it provide it's own error page... Is it possible 
somehow without patching php code and maintaining/compiling my own version?


-- 
Jakov Sosic
www.srce.unizg.hr

---

## #57838 — keisial@gmail.com — 2012-02-13T23:15:50+00:00

URL: https://externals.io/message/57829#57838 · In reply to: #57836

> 
>
>
> > […]
>
> OK but I would like it provide it's own error page... Is it possible
> somehow without patching php code and maintaining/compiling my own
> version?

Maybe there is an easier way. This extension allows to show your own
page on PHP errors:
http://svn.wikimedia.org/viewvc/mediawiki/trunk/php/wmerrors/

---

## #57839 — Jakov Sosic — 2012-02-13T23:21:10+00:00

URL: https://externals.io/message/57829#57839 · In reply to: #57838

> Maybe there is an easier way. This extension allows to show your own
> page on PHP errors:
> http://svn.wikimedia.org/viewvc/mediawiki/trunk/php/wmerrors/

This:
* Don't strip symbols, deadlocks are still occurring and we need to find 
out why

does not sound very promising but I will give it a try in the 
development environment.


Thanks everyone for any help provided so far. Every idea is welcome.




-- 
Jakov Sosic
www.srce.unizg.hr
