Sometimes when golfing in PHP, one uses tricks as reading/pushing to an inexistent variable, or using deprecated functions such as split(), but those things outputs Warnings and Notices, which by themselves are not really errors and don't change how the code works.

Is there any policy regarding the output of these type of errors?

Should I add provisions to remove or hide the warnings in my code even if the questions doesn't ask it as a requirement or should I consider that the PHP configuration has error_reporting = 0?

I have seen C answers that output compiler warnings (the closest equivalent I can think now)

share
    
I think you can say "This submission will generate PHP warnings that can be suppressed by using php ./program.php 2>/dev/null"? –  ace May 30 at 16:32
    
@ace wouldn't that also suppress the program's normal output? –  Einacio May 30 at 16:37
2  
Only if your "normal" output is to stderr. –  ace May 30 at 16:42
    
@ace by default php sends errors to stdout, unless the ini directive display_errors is set to 'stderr' –  Einacio May 30 at 16:50
11  
I'd even go so far as to say that abusing warnings is encouraged, in the spirit of code golf. ;-) –  Doorknob May 30 at 17:02
add comment

2 Answers

There currently is no policy about that, but this is my opinion:

  • Does the question explicitly disallow code that can lead to a Warning/Notice? Then it is disallowed.
  • Does the question say nothing about such code? Then it would say it is allowed (and you can assume that error_reporting = 0), because none of the rules say that it is disallowed.
share
    
the question has been in my mind for a while, but i posted now after this question:codegolf.stackexchange.com/questions/28801/missing-odd-numbers in which that rule was added after i posted my solution –  Einacio May 30 at 16:38
    
@Einacio: A rule update after an answer is posted is discouraged, because it can invalidate answers, and it invalidated yours. I'll remove that rule. –  ProgramFOX May 30 at 16:52
    
actually, i had to add 1 character to avoid a warning. the decrease was beacuse a reorganization of code (which didn't output errors). anyways, this question is to see if we can have some official policy regarding this, i don't care about the specifics of that answer –  Einacio May 30 at 16:57
    
@Einacio: I have removed that rule now and I leaved a comment. –  ProgramFOX May 30 at 16:58
add comment

PHP isn't exactly the most competitivie golfing language, but I've done my best in the past to give it fair representation. Whenever I post anything in PHP, I assume the following php.ini settings, without explicitly mentioning them:

  • short_open_tags = on
  • display_errors = stderr

Routing warnings and errors to stdout by default is perhaps one of the worst decisions ever made by any language development team, ever. Imagine, for example, an error message - displayed in the browser - detailing exactly which mysql function failed, and why. Brilliant.

Error messages haven't been disabled, they've just been re-routed to the proper channel. I think I have good precedent to assume this: both phpGolf and Anarchy Golf assume the same settings. And for both sites, stderr is ignored.

share
1  
i know it's not competitive, that's why i try to use it anyways. i don't have to imagine the mysql error in the wild, i have seen it too often already –  Einacio Jun 2 at 14:10
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .