Re: [Q] use of 'use' available?

From: Date: Thu, 01 Jun 2000 12:45:47 +0000
Subject: Re: [Q] use of 'use' available?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-788@lists.php.net to get a copy of this message
Hi chagenbu! On Wed, 31 May 2000, chagenbu@wso.williams.edu wrote: > Quoting Ken Minx <ken.minx@consultsource.com>: > > > You could set a unique variable in 'mylib.php', for instance, then have each > > page check for the variable and/or contents. If it isn't present, require or > > include. > > I'm well aware of that, and it's something I've done before. But it's an > ugly > solution, and there's no guarantee that your "unique" variable won't clash > with > something that someone is using - _especially_ in the case where you're > distributing a library meant to be used in other code. A clean way to include > code only once is well within the scope of the language, IMHO. > well, currently I'm doing something like : suppose I have some `php libs', for the FOO application, then [foo_db.inc] <?php if(!defined('FOO_DB_IFACE')) { define('FOO_DB_IFACE',1); /* code goes here */ }?> [bar.php] include 'foo_db.inc'; /* use it here */ in the very manner of C's `include'. But 'use' offered a more natural form of doing this, and also allowed you to omit the extension . Also it's shorter to write :) and more Perl like ... I'm goona cope w/ it anyway . -- teodor

« previous php.general (#788) next »