when including a file using php function not work?
- by John Smiith
MY PHP FUNCTION IS
function functionName()
{
include($_SERVER['DOCUMENT_ROOT']."/path/file.php");
}
Content of File.php is
$foo = 'bar';
Calling function (content of file test.php)
functionName();
When call function and variable not work
echo $foo; <- not works
But when adding code below its works (content of file test.php)
include($_SERVER['DOCUMENT_ROOT']."/path/file.php");
echo $foo; <- its works