考虑以下代码
// Grab some values to be used later ('Y' or 'N')
$daycareactive = isActiveProgramType($companyid,'daycare');
$oscactive = isActiveProgramType($companyid,'osc');
$preschoolactive = isActiveProgramType($companyid,'preschool');
$ecsactive = isActiveProgramType($companyid,'ecs');
$grouphomeactive = isActiveProgramType($companyid,'grouphome');
$dayhomeactive = isActiveProgramType($companyid,'dayhome');
$otheractive = isActiveProgramType($companyid,'other');
echo "Daycare Active 1: ".$daycareactive;
function setFirstAvailablePage(){
global $daycareactive, $oscactive, $preschoolactive, $ecsactive, $grouphomeactive, $dayhomeactive, $otheractive;
echo "Daycare Active 2: ".$daycareactive;
...other stuff goes here
}
以上结果如下:
Daycare Active 1: N
Daycare Active 2:
为什么第二个空白?
我正在使用关键字global,所以据我所知,它应该引入在此函数之外定义的变量。为什么不起作用?