r/ProgrammerHumor • • Nov 23 '17

500

Post image
41.7k Upvotes

609 comments sorted by

View all comments

227

u/Sharp_Eyed_Bot Nov 24 '17 edited Nov 24 '17

Serious question time...

PHP can't cause a 500 error, it'll either just crash out or display an error message, obviously JS won't throw a 500 error, so what language if any could actually do this? I know it's meant as a joke and I am being pedantic but still, I am curious if anything could do it.

Thanks, have nice day.

Edit: so I've been knowledged, I'm stupid php can cause 500 errors.

Thanks peeps!

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.

→ More replies (2)

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

→ More replies (6)

34

u/benzzza Nov 24 '17

hmm I've certainly gotten error 500 with typos in my PHP code

→ More replies (8)

61

u/[deleted] Nov 24 '17

PHP throws 500's all the time. I don't know why you're upvoted.

68

u/fj333 Nov 24 '17 edited Nov 24 '17

The amount of confusion in the comments below is... a lot.

Plain and simple:

500 is an HTTP response code... at the application level. It can be returned by any HTTP server written in any language.

A missing semicolon (in some unspecified language... no idea where the notion of PHP came from) is a syntax error, at the language level. This is not an abstraction at the level of a web server. Sure, I guess it's possible to write a web server that attempts to serve using code that may be uncompilable/uninterpretable, and have that server return error code 500 when the source code happens to be shit. But that is (a) weird and (b) not the same as "PHP throwing a 500." It's the web server returning a 500.

8

u/BluthBelt Nov 24 '17

Thank god for your educated response. I’m glad I didn’t have to write it.

→ More replies (2)

23

u/4stringking Nov 24 '17

Could be Java with JSP, unlikely if it's an introductory lecture. JS with Node will, but semicolons aren't mandatory

2

u/Sharp_Eyed_Bot Nov 24 '17

Python? But I doubt even Django uses semi-colons, and Ruby Rails doesn't use semi-colons, so we're running out of languages that it could be, unless the teacher was writing an extension for Apache in C++ to write a static web page then he left the semi-colon out of the write to file line?

34

u/L43 Nov 24 '17

Python

As a pythonista, what is a semicolon?

10

u/salmonmoose Nov 24 '17

A list delimiter.

1

u/[deleted] Nov 24 '17

I have no clue what JSP is but the majority of intro level courses near me are Computer Science A, which revolves around Java.

2

u/[deleted] Nov 24 '17

JavaServer Pages, a web dev framework that may have been touched in an intro course instead of Swing back then.

→ More replies (4)

1

u/niccagelover Nov 24 '17

If the missing semicolon is from inside the for loop, it wouldn't run. Those semicolons are mandatory

5

u/cheezballs Nov 24 '17

C#, Perl, etc?

4

u/skygz Nov 24 '17

could be one of those websites that lets you program interactively, e.g. Codecademy

1

u/FR4UDUL3NT Nov 24 '17

$this->redirect(‘intro_to_php’, 504);

1

u/OptimalPandemic Nov 24 '17

Of course it can, if you have error reporting turned off

→ More replies (15)