I think that there are some steps that are required before asking a question on Drupal Answers, and part of those steps are listed on What information should be given when asking a question? More answers should be added to that question to cover more cases.
To make an example, a question asking about which module to use that doesn't show any effort to search it on Drupal.org could be closed for lack of search effort.
I would extend the lack of search to lack of necessary steps, which would include also those questions asking why the code showed in the question doesn't work, when the reason is that the code contains a syntax error. In this case, the required step should be checking the code doesn't have any syntax error, for example by using
php -l <file>, or any tool for syntax checking the used IDE has.
We could adopt the off-topic closing reason Stack Overflow has:
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also What information should be given when asking a question?
In the case of questions asking for modules, the minimal understanding of the problem would include understanding that the place for looking for Drupal modules is Drupal.org; in the case of questions about troubles with a module, that would be understanding that Drupal.org probably has documentation for the module, which could be also linked from the project page for the module.