Re: What mechanism may be used in PHP that will act as #define and #ifndef
- From: petersprc <petersprc@xxxxxxxxx>
- Date: Sat, 29 Mar 2008 17:29:53 -0700 (PDT)
Hi,
Use require_once instead of require to ensure the include is evaluated
only once per interpreter.
Regards,
John Peters
On Mar 29, 8:14 pm, Andrew Falanga <af300...@xxxxxxxxx> wrote:
The question is I have a base class in file1 and files file2 and file3
both contain classes that derive from the base class in file1. I'm
running in to a redefinition problem when I'm loading the files. What
I'd like is something like this:
file1:
<?php
// defining stuff
?>
file2:
<?PHP
require("path/to/file1");
// doing important stuff
?>
file3:
<?php
require("path/to/file1");
//doing important stuff
?>
Then in the "main" files I have:
main:
<?php
require("path/to/file2");
require("path/to/file3");
// do important stuff
?>
Now, I'm getting the redefinition problem here. In C or C++, I'd do:
#ifndef SOMETHING
#define SOMETHING
// code here
#endif
Is there something that would do this php? I haven't actually tried
wrapping the base class definition in a conditional because I thought
I remember reading that PHP uses the same scope rules as C and C++.
If I define something inside the scope of a conditional, that
something goes out of existence when that scope moves out. Is this
true, or would a conditional be the answer?
Thanks,
Andy
.
- References:
- What mechanism may be used in PHP that will act as #define and #ifndef
- From: Andrew Falanga
- What mechanism may be used in PHP that will act as #define and #ifndef
- Prev by Date: What mechanism may be used in PHP that will act as #define and #ifndef
- Next by Date: Re: Displaying graphs on html pages
- Previous by thread: What mechanism may be used in PHP that will act as #define and #ifndef
- Next by thread: Sexual pleasure,Lactation Madam SP 3
- Index(es):
Relevant Pages
|
|