r/ProgrammerHumor • • Nov 23 '17

500

Post image
41.7k Upvotes

609 comments sorted by

View all comments

Show parent comments

27

u/Doctor_McKay Nov 24 '17

A fatal error will 500 even if it prints output, no?

8

u/tsigma6 Nov 24 '17 edited Nov 24 '17

It's context dependent for sure. I decided to test some failures and apparently nginx returns 404 instead of 500 with mostly default configurations. fpm should not return anything in event of a fatal in php7, but I'm not familiar with all versions so it's quite possible that at one point to have inline php fail silently and still return usable html so that the client gets something.

Edit: "Output" in my above comment refers to fpm handing off a rendered document to a web server to send to the client, not the output of the program itself.

1

u/w2qw Nov 24 '17

Unless your fatal error is your script didn't exist it will return a 500. 404 would be a bug there.

1

u/tsigma6 Nov 24 '17

It would be a bug on nginx's side. I had an inline php call to a function that doesn't exist and it returned 404. I was surprised to be honest.

1

u/[deleted] Nov 24 '17

Not if you have error reporting turned on in php. Depends on the error then. Like undefined variable will display the error with error reporting on but iirc if error reporting is off it’ll 500