Justtechjobs.com Find a programming school near you






Online Campus Both


php4-beta | 199912

Re: [PHP4BETA] 'use' keyword From: Stig Bakken (ssb <email protected>)
Date: 12/02/99

On Thu, 2 Dec 1999, Michal Kolodziejczyk wrote:

| On Thu, 2 Dec 1999 rasmus <email protected> 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

-- 
PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
To unsubscribe, e-mail: php4beta-unsubscribe <email protected>
For additional commands, e-mail: php4beta-help <email protected>
To contact the list administrators, e-mail: php4beta-admin <email protected>