I have a file(color.php) included in my index.php. In the included file, I have defined some variables and functions.
(color.php)
<?php
$colors = array(0xffffff, 0x000000, 0x000000, 0x808080);
function getColors() {
global $colors;
return $colors;
}
?>
Below is my main file(index.php).
<?php
require_once('color.php');
class Test {
function Test() {
var_dump(getColors()); // returns NULL
}
}
?>
Why is it that calling the getColors() function, it returns NULL which is supposedly, will return an array of colors? Am I missing something? Or is there any config needed in php.ini? Any help would be much appreciated. Thanks!