Re: Coding Standards
| From: | Daniel Convissor | Date: | Tue, 29 Jun 2004 15:07:28 +0000 |
| Subject: | Re: Coding Standards | ||
| References: | 1 2 3 | Groups: | php.pear.doc |
| Request: | Send a blank email to pear-doc+get-4544@lists.php.net to get a copy of this message | ||
Hi Aidan:
On Tue, Jun 22, 2004 at 09:56:38PM +1000, Aidan Lister wrote:
> [dan wrote --dc]
> > [aidan wrote --dc] [aren't attributions helpful? --dc]
> > >
> > > define ('CAT_PACK_BASE', basename(__FILE__));
> > > require_once CAT_PACK_BASE . 'Driver/mysql.php';
> >
> > Yuck. Defining constants is expensive. Plus it obfuscates what's being
> > included.
>
> True, but it's faster and allows you to check if a file exists before
> including it.
But, using basename() doesn't speed that up at all. You'd still be left
with a relative path, which relies on searching the include path.
Anyway, your revisions to the wording are good. For clarity, the "Either
of these will ensure" paragraph should follow the first paragraph. Also,
let's use the <command> tag rather than <function> tag so the "()"
don't
get appended. Finally, I'd reword the "The only places where" paragraph
as follows:
The only places where
<command>include</command>/<command>require</command>
should be used instead of
<command>include_once</command>/<command>require_once</command>
is when the included file contains <emphasis>procedural</emphasis>
code that <emphasis>must</emphasis> be included again.
For example, the include file contains procedural code that
behaves differently depending on the location it is included from.
Thanks for your efforts,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409