note 3198 deleted from function.include by philip
| From: | philip@php.net | Date: | Fri, 02 Nov 2001 06:48:45 +0000 |
| Subject: | note 3198 deleted from function.include by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20270@lists.php.net to get a copy of this message | ||
I also ran into the problem that many others reported about multiple includes.
I liked the idea the person had about useing something simular to c's #ifdef and #def, but when
I tried his example it didn't work becouse I was including the file inside of a function the
first time, which made the varible local. Then when I tried to include it again it didn't find
the previous local varible.
The solution I came up with was to use constants like so:
if(GETSETTINGS_INCLUDED==1){
return;
}
define("GETSETTINGS_INCLUDED", 1);
Since constants are always global, this works great. Of course the fact that constants are global
might not be such a great idea, I can see where it would be handy to have private constants in a
class definition. But this will work.