我需要访问在函数内的另一个 php 文件中声明的变量。我该怎么做?
一个.php
<?php
$global['words']=array("one","two","three");
echo "welcome"
?>
b.php
<?php
$words = $global['words'];
require_once('a.php');
print_r($global['words']);
function fun()
{
print_r($global['words']); // not displaying here
}
fun();
?>
现在我可以访问 b.php 文件中的“$global['words']”变量,但不能在函数内访问,我怎样才能使其在函数内可见?