I'm not a PHP Developer but I see a few problems with this.

Since a PHP script is re-evaluated/"compiled" on each execution it would
mean PHP would have to look through all your .php files for this file. This
could be very time consuming, espically since it has to do it every
execution.

Also what happens if you spell a function wrong, OR it finds 2 functions
with the same name in different .php files.

I don't think its got any real advantage over the fact that it just lets you
be lazy. It wouldn't be any quicker in any way.

If this was a compilable language then sure it would of been nice, like C
does searching through .h files, but since its not I don't think its a good
idea.

Andrew
----- Original Message -----
From: "Brian T. Allen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 13, 2003 8:21 PM
Subject: [PHP-DEV] Feature Request: Auto Include a Function


> Hi,
>
> Please accept my apologies in advance if this is not the correct place
> for this request.
>
> This may exist, but I haven't been able to find it, and I think it would
> be REALLY helpful and convenient.
>
> The idea is this:
>
> When you write a script and call a function:
>
> <?php
>
> $whatever = previously_uncalled_function("one","two");
>
> ?>
>
> PHP could automatically look for a file named
> "previously_uncalled_function" in your /include/functions/ (or whatever)
> directory.
>
> This would eliminate a LOT of include() and require() calls (or at least
> make them automatic) in a script.  The function would only get read in
> if it was used.  Functions could still be explicitly included or
> required as they currently are.
>
> I *think* the overhead would be about the same as the initial include()
> or require() call would have been.
>
> This would be very convenient.  When you create a new function you drop
> it in that directory (with a very specific, unique name, of course), and
> it can immediately be called anywhere in the site.  And, you only incur
> the disk IO to read it when its used for the first time in a script.
>
> The 3 things I want to avoid are:
>
> 1)  Explicitly including every function, every time it's needed.
> 2)  Disk IO of including a function when it's not needed.
> 3)  Taking the easy route and including a file with a bunch of functions
> when most won't get called.
>
> Does this already exist, or is this a good idea (if not, any reasons
> why)?  I personally would love to see it implemented if it isn't
> already.
>
> One possibility for implementation is just prior to the "undeclared
> function" error message, try to auto include the function prior to
> generating the error message.
>
> Thanks,
> Brian Allen
> [EMAIL PROTECTED]
>
>
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

Reply via email to