Re: conditionally including classes/functions
| From: | Hugh Bothwell | Date: | Fri, 05 Apr 2002 17:58:27 +0000 |
| Subject: | Re: conditionally including classes/functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91758@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Andrew Warner [mailto:andrew@like.com]
> Sent: Thursday, April 04, 2002 11:29 AM
> To: php-general@lists.php.net
> Subject: [PHP] conditionaly including classes/functions
>
> Is it okay practice to condtionally include php files that contain
> only classes or functions (as opposed to just straight code)? The
> result is a class or function inserted right in the middle of an if{}
> block:
I would find it much more useful to do something like
a transparent include-on-first-use; for a function this
shouldn't be too hard, but I have no idea how to make it
work for a class short of wrapping every method
independantly.
function MyLazy($a) {
if (!function_exists("contentsMyLazy"))
include("contentsmylazy.php"); // define the function
return contentsMyLazy($a);
}