|
Posted by Thiago Silva on 11/16/05 00:48
Hello all,
Recently I had some problems with include/include_once.
This is the scenario:
My application uses only classes loaded through a centered __autoload()
function (no "require/include" anywere in the scripts, but in __autoload()
itself).
Now, diverse libraries use diverse extensions. For instance, Smarty class is
declared in Smarty.class.php. And many of my classes uses a simple .php
extension.
So, __autload has to *try* include_once's. Something like that:
function __autoload($className) {
include_once("${className}.php");
if(class_exists($className, false)) return;
include_once("${className}.class.php");
if(class_exists($className, false)) return;
die("class not found: $className");
}
Then, loading Smarty would generate a warning message because the first
include_once tries to load Smarty.php (wich doesn't exists).
Since those warning messages are common, naturaly I use @include_once
statements.
But, as soon as I'm writing scripts, and one of the classes included
generates an E_PARSE error, I get a blank result in my browser, because @
supress the messages.
Having explained the problem, I would like to know:
1: Is there an elegant way to resolve this?
2: What happened to php_check_syntax?
3: What was the final word about include() behavior regarding E_PARSE error?
Reading and searching the bug database, I read some posts that seemed to
indicate that include() should *not* halt on E_PARSE errors, but then, php5
does halt the execution.
4: Halting the execution on E_PARSE error generated through an include() is
a coherent/expected behavior? (it doesn't seem to me).
5: Why? (depending on the answer to that question, I'll head to
bugs.php.net).
Thanks,
Thiago
Navigation:
[Reply to this message]
|