note 3198 modified in include by ronabop
| From: | ronabop@php.net | Date: | Sat, 12 Aug 2000 05:49:54 +0000 |
| Subject: | note 3198 modified in include by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-1469@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.
http://www.php.net/manual/function.include.php