【发布时间】:2011-03-30 03:07:20
【问题描述】:
我的 index.php 中包含一个文件 (color.php)。在包含的文件中,我定义了一些变量和函数。
(color.php)
<?php
$colors = array(0xffffff, 0x000000, 0x000000, 0x808080);
function getColors() {
global $colors;
return $colors;
}
?>
下面是我的主文件(index.php)。
<?php
require_once('color.php');
class Test {
function Test() {
var_dump(getColors()); // returns NULL
}
}
?>
为什么调用 getColors() 函数,它返回 NULL 应该返回一个颜色数组?我错过了什么吗?或者 php.ini 中是否需要任何配置?任何帮助将非常感激。谢谢!
【问题讨论】:
标签: php function variables null global