[Phpmyadmin-devel] header.inc.php3 safty net
gandon at isia.cma.fr
Fri Jul 27 11:42:42 CEST 2001
> > If I understand correctly the manual, this code won't work:
> > if (!defined('__HEADER_INC__'))
> > require("./header.inc.php3");
> > Marc
> However, this will:
> if (!defined('__HEADER_INC__'))
> The only problem is that variables defined in header.inc.php3
> and not in
> the require()ing file won't be visible outside of the braces.
No. Global variables defined in header.inc.php3 *will* be visible
outside of braces if __HEADER_INC__ is defined.
I made the test and that behaviour did not change through php versions.
For more information, consult that page about variables scope in php :
Note that if __HEADER_INC__ is not defined, the content of header.inc.php3
will be included but not parsed. That's why things will be as if it had not
As far as I'm concerned, I would really prefer putting the
directly inside header.inc.php3 as when coding in C or C++.
I find it quite a hell to always put such an if each time header.inc.php3
has to be required (and what if we change __HEADER_INC__ in HEADER_INC or
whatever?). With a single 'if' in header.inc.php3 the final result will
be exactly the same.
More information about the Developers