[Phpmyadmin-devel] header.inc.php3 safty net

Ignacio Vazquez-Abrams ignacio at openservices.net
Thu Jul 26 19:33:09 CEST 2001


On Thu, 26 Jul 2001, Marc Delisle wrote:

> Hi Jeremy,
>
> from the PHP manual:
> --------------------
> require() is not actually a function in PHP; rather, it is a language construct. It is subject to
> some different rules than functions are. For instance, require() is not subject to any containing
> control structures.
>
> Unlike include(), require() will always read in the target file, even if the line it's on never
> executes. If you want to conditionally include a file, use include(). The conditional statement
> won't affect the require(). However, if the line on which the require() occurs is not executed,
> neither will any of the code in the target file be executed.
> -----------------------
>
> 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__'))
  {
    require("./header.inc.php3");
  };

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.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>






More information about the Developers mailing list