What mechanism may be used in PHP that will act as #define and #ifndef
- From: Andrew Falanga <af300wsm@xxxxxxxxx>
- Date: Sat, 29 Mar 2008 17:14:22 -0700 (PDT)
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
.
- Follow-Ups:
- Prev by Date: Displaying graphs on html pages
- Next by Date: Re: What mechanism may be used in PHP that will act as #define and #ifndef
- Previous by thread: Displaying graphs on html pages
- Next by thread: Re: What mechanism may be used in PHP that will act as #define and #ifndef
- Index(es):
Relevant Pages
|