PHP全局关键字不工作

PHP全局关键字不工作,php,global,Php,Global,我有以下文件,它包括一个名为'vote.php'的文件,其中包含一些需要的函数 require _PATH_.'/core/includes/vote/vote.php'; $ip_address = $_SERVER['REMOTE_ADDR']; $voting_sites[0]['name'] = 'Runelocus'; $voting_sites[0]['url'] = 'http://www.runelocus.com/top-rsps-list/vote-39865-Hydrasc

我有以下文件,它包括一个名为'vote.php'的文件,其中包含一些需要的函数

require _PATH_.'/core/includes/vote/vote.php';
$ip_address = $_SERVER['REMOTE_ADDR'];
$voting_sites[0]['name'] = 'Runelocus';
$voting_sites[0]['url'] = 'http://www.runelocus.com/top-rsps-list/vote-39865-Hydrascape%20HD%20639%20Beta%20-%20Original%20Staf/?id2='.getIPString($ip_address);
$voting_sites[0]['callback'] = true;

$voting_sites[1]['name'] = 'Top100Arena';
$voting_sites[1]['url'] = 'http://www.top100arena.com/in.asp?id=85854&incentive='.getIPString($ip_address);
$voting_sites[1]['callback'] = true;

$voting_sites[2]['name'] = 'TopG';
$voting_sites[2]['url'] = 'http://topg.org/Runescape/in-393646-'.getIPString($ip_address);
$voting_sites[2]['callback'] = true;

$voting_sites[3]['name'] = 'RSPS-List';
$voting_sites[3]['url']= 'http://www.rsps-list.com/index.php?a=in&u=Hydrascape&id='.getIPString($ip_address);
$voting_sites[3]['callback'] = true;
其中包括'vote.php',但是我无法访问任何getIpString函数中的$char_表print_r返回null,即使我使用的是global关键字,这是为什么

$char_table = array("k", "V", "R", "c", "H", "x", "i", "a", "p", "z", "W", "Y");
echo 'v1';
/*
 * Converts an Ipv4 address to an 'encrypted' version able to pass on to voting sites
 * which will be received by callbacks
 */
function getIPString($ip) {
    $ret = "";
    global $char_table;
    die(print_r($char_table, true));

    for($i = 0; $i < strlen($ip); $i++){
        $char = $ip{$i};
        if($char == '.')
            $ret .= 'E';
        else
            $ret .= $char_table[$char];
    }
    return addslashes($ret);
}
/*
 * Reverses an 'encrypted' ip string back to a normal Ipv4 address
 */
function reverseIPString($string) {
    $ret = "";
    global $char_table;
    for($i = 0; $i < strlen($string); $i++) {
        $char = $string{$i};

        if($char == 'E') {
            $ret .= '.';
        } else {
            for($x = 0; $x < sizeof($char_table); $x++){
                if($char == $char_table[$x]) {
                    $ret .= $x;
                    break;
                }
            }
        }
    }
    return addslashes($ret);
}


?>
$char_table=数组(“k”、“V”、“R”、“c”、“H”、“x”、“i”、“a”、“p”、“z”、“W”、“Y”);
回声“v1”;
/*
*将Ipv4地址转换为能够传递到投票站点的“加密”版本
*这将通过回调接收
*/
函数getIPString($ip){
$ret=“”;
全球$char_表;
模具(打印($char_table,true));
对于($i=0;$i