How does include(\'./code.php\'); work? I understand it is the equivalent of having the code \"pasted\" directly where the include occurs, but, for example:
Include does not behave like copy paste.
Here is a demonstration using PHP Strict Type Declarations
However, if I call this function from an external file
Strict types are enabled for the file that the declare statement was added (function.php)
It does not apply for any function calls made from an external file (caller.php)
because PHP will always defer to the caller when looking to evaluate strict types.
Require doesn't work like copy/paste
For further understanding,
Short answer on how PHP script is Executed &
A more comprehensible explanation on what include/require really does in php