Re: [PHP4BETA] 'use' keyword

From: Date: Thu, 02 Dec 1999 14:09:38 +0000
Subject: Re: [PHP4BETA] 'use' keyword
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-7242@lists.php.net to get a copy of this message
On Thu, 2 Dec 1999, Michal Kolodziejczyk wrote: | On Thu, 2 Dec 1999 rasmus@php.net wrote: | | > > If someone does use "../foo.php" and .. is /www/php what would you expect | > > in the array? | > > $USED_PACKAGES["foo.php"] -> /www/php/foo.php? | > | > Yeah, I think that is what I would expect. Symbolic links might be | > another issue. We might want to follow any symbolic links and use the end | > point. | | I would expect it in mosc cases, but not always. Let assume I try to write | portable and relocatable package, so I always use("../inc/file.inc"), and | in another place I want ti check if it is included. With absolute path I | must know the base of the system then, because there is no "../inc/file" | in $USED_PACKAGES. How about additional get_used_packages_absolute() or | conditional parameter like get_used_packages($relative=0)? Just to make this clear: "use" is specifically intended for loading PEAR packages. It is not a generic replacement for include() or require(), it has a very specific purpose. Even relative paths is wrong in this context. Actually, relative paths are _more_ wrong than absolute paths, because you have to change it if you move the file to another directory. PEAR packages are supposed to be installed in one or more designated directories that appear in your include path. The only special check "use" needs is testing whether the first character of its parameter is "." or "/", to avoid that people try using it for stuff that include() and require() are better suited for. - Stig

« previous php.version4 (#7242) next »