Possible Duplicate:
How to use include within a function?
i have two file
inc.php file
<?php
$var1 = "foo";
$var1 .= "bar";
?>
test.php File
<?php
function getcontent($file) {
include ($file);
}
getcontent('inc.php');
echo $var1;
?>
When i run test.php it give me error in output
Notice: Undefined variable: var1 in \www\test.php on line 7
But when i change my test.php file to this
<?php
include ('inc.php');
echo $var1;
?>
its works, and give me output fine
foobar