In Php when evaluating Include / Require?
With Php, when is the included file included? Is it during the preprocessing phase or during the evaluation of the script?
I currently have several scripts that use the same header and footer code that do input validation and exception handling. Like this:
/* validate input */
...
/* process/do task */
...
/* handle exceptions */
...
So, I would like to do something like this
#include "verification.php"
/* process/do task */
...
#include "exception_handling.php"
So if the include happens as a preprocessing step, I can #include "exception_handling.php", but if not, then any exception will kill the script before it has a chance to evaluate the include.
thank
source to share
PHP.net: include gives a basic example:
vars.php
<?php
$color = 'green';
$fruit = 'apple';
?>
test.php
<?php
echo "A $color $fruit"; // A
include 'vars.php';
echo "A $color $fruit"; // A green apple
?>
so inclusion happens when it's done in code.
Edit: fixed url.
source to share
PHP has no preprocessor. Running a line with a "#" character makes a comment line. You must do this to include the file:
include ("exception_handling.php");
include 'exception_handling.php'; // or this, the parentheses are optional
Read this for more information: http://php.net/include
source to share