2

Example 1

<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
// I guess I miss a semicolon
a()
b()

Example 2

<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
// I open php twice
<?php

I cannot see any error instead 500 status code is triggered. error.log is also empty. I'm not sure what kind of errors is this: parse, syntax? How do I display or log an error in such case? This bothers me for a long time now.
System info is very typical. phpinfo()

PHP Version 7.4.25
Apache/2.4.51 (Unix)
display_errors on
display_startup_errors on

edit: tested php-5.6 and php-8.1 seems the same. I can see logs PHP Parse error: syntax error, unexpected 'b' (T_STRING) on VPS, but shared hosting doesn't log them...
solution: duplicated question explains why errors are not being shown. for me there's an issue with hoster's error.log.

Hebe
  • 661
  • 1
  • 7
  • 13
  • 1
    Are there any error handlers set in your code? You can also check inside `/var/logs` folder on the server. – nice_dev Jul 15 '22 at 13:43
  • Register your own error handler and output whatever content you want on error – Justinas Jul 15 '22 at 14:07
  • You'd rather add it to your *google search* – Your Common Sense Jul 15 '22 at 14:16
  • @YourCommonSense reverted the title so others might find it – Hebe Jul 15 '22 at 14:24
  • 1
    The whole situation is bizarre. *You never develop on a live server* for starter. You are supposed to make your code work on a local PC and only then upload it on a live server, and so parse errors won't be a problem. Another strange thing is, given phpinfo() called via web-server is *indeed* showing display_errors on, and still no errors displayed, it means there is something wrong about this hosting. And given there are no logs either - I'd quit this hosting at once. – Your Common Sense Jul 15 '22 at 14:25
  • 1
    And of course you *don't* want to display errors on a live server at all. – Your Common Sense Jul 15 '22 at 14:33

0 Answers0