Drupal-standard way of including files in modules
For Drupal 7, see module_load_include() and using module_load_include() for a file nested within a module directory.
At least, if we can trust the node module:
include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
This was in a conditional statement, so Agaric doesn't yet know if require_once might be preferred for always-included file. We doubt it; if a file isn't included it either breaks things or it doesn't. Require guarantees PHP will come to a screeching halt.
Now, I started looking at all this because I was getting inexplicable parse errors from an include file (for instance, delete everything, still get an error on line one). The problem did not have to do with how the file was included.
Here's one of several parse errors it generated:
Parse error: syntax error, unexpected $end in /Users/ben/workspace/drupalcvs/contributions/modules/cmt/cmt_admin.inc on line 1
Here's the commit message with the, uh, fix:
that was so strange. The whole cmt_admin.inc file was refusing to run; best I could determine PHP was not interpreting its spaces as spaces but running everything together. A Mac-Unix file exchange screw-up? Anyway, wasted a lot of time, used the content_types.inc from node module as an emptied out file and pasted my content into TextEdit, and then SubEthaEdit (TextWrangler may be the thing screwing it all up) and it works.
More accurate to say that it could not interpret line breaks as white space.
When the file consisted only of
it gave the error of no such function as "phpdebug_print_backtrace" -- at Agaric we call that a clue.