views:

147

answers:

2

Is there a problem with some versions of PHP and file names which look like this:

report.class.php

I tried to use one and it failed once and worked once, but I can't replicate the failure. So I'm not sure exactly what the cause is, prefer using the period-separated filenames, but would strongly prefer not to be using "fragile" file names on my site.

+7  A: 

File names with multiple periods in them work fine in PHP includes. I wish I could help more, but since you can't replicate the failure, I can only assure you that it isn't the filename.

Consider naming your classes in the pattern class.xxx.php instead though. They will be alphabetized together that way.

Frank Crook
+4  A: 

Did you remember to quote your filename?

e.g., it should be:

include 'report.class.php';

not

include report.class.php;

In the latter case, the lack of quoting causes PHP to interpret the strings as constants, then fail with an E_NOTICE, and assume that you intended to use string literals. The periods will be interpreted as string concatenation operators, and PHP will end up interpreting your command as equivalent to the following:

include 'reportclassphp';

If this is, in fact, what happened, then make sure to turn PHP NOTICE level errors, and pay attention to them. While NOTICE level errors may seem obnoxious, most of the time they may hint at actual logic issues in your code.

Frank Farmer
I suspect this is what happened: I've been teaching myself PHP, and made some fairly elementary errors along the way. Thanks!
ehdv