You are here: include/include_once php_check_syntax() / E_PARSE errors « PHP « IT news, forums, messages
include/include_once php_check_syntax() / E_PARSE errors

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация