Re: [PHP-DEV] downgrade undefined function from fatal error

2002-12-14 Thread Ivan Ristic
John Coggeshall wrote:

There is absolutely no reason why you cannot simply include your
functions in your scripts


  Erm, to avoid manual work? There is no reason whatsoever
  to include files manually.

  Right now you must pre-load every single
  class you intend to use in the application. This may or
  may not be a problem, depending on the size of the application,
  since the engine must parse hundreds of KB of code. I use classes
  for everything and I would prefer to have one file per class,
  and to load classes on demand. Makes maintenance much easier.

  The patch for this is trivial. It was made a while ago and
  it seems that it still works (just tried it with 4.2.3)

http://www.webkreator.com/php/configuration/automatic-php-class-loading.html

--
Ivan Ristic, http://www.webkreator.com


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




RE: [PHP-DEV] downgrade undefined function from fatal error

2002-12-14 Thread John Coggeshall

There is absolutely no reason why you cannot simply include your
functions in your scripts. If you are really lazy, you can even
auto_prepend an include file.

John


>-Original Message-
>From: Dave [Hawk-Systems] [mailto:[EMAIL PROTECTED]] 
>Sent: Friday, December 13, 2002 8:56 AM
>To: [EMAIL PROTECTED]
>Subject: [PHP-DEV] downgrade undefined function from fatal error
>
>
>reviewed and did a couple of searches on this prior to signing 
>up to this particular list...
>
>Is this a reasonable consideration for changes to PHP's 
>handling of undefined functions?
>
>Currently, calling a previously undefined function generates 
>an E_ERROR, and halts the script as a cirtical failure meaning 
>we can't handle the error as we do others (this is clearly documented).
>
>What I am not clear on is why an undefined function should 
>necessarily be a fatal error with no change to code the script 
>to handle the error.  For example
>
>function eh($type, $msg, $file, $line, $context){
>   # code to parse $msg for 
>/undefined\040function:\040(.*)\(\)/,$match
>   # check specified directory for the function:
>   # include the file if exists (./functions/$match[1].php)
>   # try to resume
>   # if we can't find it, halt with die()
>}
>
>error_reporting(0);
>set_error_handler("eh");
>
>undefined_function();
>?>
>
>This would seem much more intuitive, and allow collection of 
>massive amounts of sharable and accessible functions to be 
>contained in shared directories, and not have to worry about 
>identifying them all at the head of all pages, or including 
>functionsthat would not be required.
>
>Currently as a workaround we are using the following logic;
>
>function func($f_name){
>   if(!function_exists($f_name)){
>   # function doesn't exists, needs to be included
>   require('/path/to/functions/'.$f_name.'.php');
>   }else{
>   # function already exists, no action required
>   }
>   return $f_name;
>}
>
>$database=call_user_func(func('DatabaseConnect'),'var1','var2');
>?>
>
>But this results in code that isn't quite as intuitive.
>
>Thoughts? Comments? "You are nuts"?
>
>Dave
>
>
>
>-- 
>PHP Development Mailing List 
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




Re: [PHP-DEV] downgrade undefined function from fatal error

2002-12-13 Thread Derick Rethans
On Fri, 13 Dec 2002, Dave [Hawk-Systems] wrote:

...

>  function func($f_name){
>   if(!function_exists($f_name)){
>   # function doesn't exists, needs to be included
>   require('/path/to/functions/'.$f_name.'.php');
>   }else{
>   # function already exists, no action required
>   }
>   return $f_name;
> }
> 
> $database=call_user_func(func('DatabaseConnect'),'var1','var2');
> ?>
> 
> But this results in code that isn't quite as intuitive.
> 
> Thoughts? Comments? "You are nuts"?

"You are nuts" (read the archives, this was discussed before)

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


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