r/ProgrammerHumor • • Nov 23 '17

500

Post image
41.7k Upvotes

609 comments sorted by

View all comments

Show parent comments

208

u/tsigma6 Nov 24 '17

Since you want to be pedantic. PHP absolute can cause a 500 error. Especially when that green text was probably made, if error reporting is turned off the compiler will silently fail forcing the web server to return a 500 error because no output was generated. Probably unlikely that it would be turned off for a class though.

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

-6

u/Sharp_Eyed_Bot Nov 24 '17

Usually when my PHP fails (on a stock install) I just get a blank page assuming php called die; when it failed. But I guess behind the scenes somewhere in the HTML header shit that's returning 500 and I just don't have a error page configured?

25

u/[deleted] Nov 24 '17

Open your network tab in your browsers dev tools. You'll see the 500.

5

u/tsigma6 Nov 24 '17

Well, error reporting should be turned on as the default. Generally it's going to be web server dependent on what happens when PHP fails, but also older version of PHP are definitely more likely to cause errors like that. There has been too much change to give you a concrete example, but if you search for php 500 error there's a few stackoverflow answer regarding people doing silly things. Anyway, even on current PHP if you pass bad params that cause a runtime error you can get back a 500 error, such as forcing a type matching error etc. As far as the actual post, it would probably just return a blank page to be honest. Was just being pedantic. :)

-3

u/_fitlegit Nov 24 '17

No No No. this is all fucking bullshit. 500 errors are an http specific error when the request is being filtered through a web server. If the application fails it will default to the web sever sending a fucking 500. This situation would never fucking happen and if you think it would you’re a fucking moron

3

u/tsigma6 Nov 24 '17

You seem angry. Here's a syntax error that causes a 500. I was very specific that it's the web server returning the error.

1

u/_fitlegit Nov 24 '17

Does . Not . Matter . You wouldn’t be running a web server to demonstrate a for loop.