Derick Rethans wrote:

On Sat, 8 May 2004, Lukas Smith wrote:

By throwing an exception inside require with the necessary information
it would be able to cleanly handle this situation without having to
silence this error and then parsing the error message. And it would
obviously be BC compatible as uncaught exceptions are fatal.


A require should fail if it can't find the file, no nice handling as
it's CLEARLY a programmers error.

Actually I was essentially suggesting a way to make include superfluous (to some extend anyways). The issue I am trying to resolve, as I described in the original mail, was to better handle condition includes.


If you want to conditionally include some code it is currently not possible to easily (as in not having to parse error messages) determine if one of the following has happends:
1) the file is missing
2) the file had parse errors
3) the file simply returned false


While case 3) I have never come across in real life it still means that 1) and 2) are problematic. file_exists() obviously is not sufficient to determine 1) if you use the include path directive. So why would you want to know (and therefore why would simply silencing with @ not be sufficient)?

For example you have a framework with optional functionality that the user needs to install/enable/buy. Or you are loading modules on demand which may be structured in several ways (the first example is better then this second example). In order to better inform the user why a certain feature is unavailable you obviously want to be able to differentiate between the two .. since only one of them really is an error. It simply makes debugging easier.

I think this is a very real problem and it would be nice to have a solution which does not require user land extensions to file_exists() or error message parsing.

Again the solution I suggested would very cleanly handle this imho, but I am open to other solutions (allthough I wouldnt mind not having to add some additional functional call like an extended version of file_exists() ..).

regards,
Lukas Smith
[EMAIL PROTECTED]
_______________________________
  BackendMedia
  www.backendmedia.com
  [EMAIL PROTECTED]

  Linn Zwoch Smith GbR
  Pariser Str. 44
  D-10707 Berlin

  Tel +49 30 83 22 50 00
  Fax +49 30 83 22 50 07

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to