close

https://stackoverflow.com/questions/13530465/how-to-declare-a-global-variable-in-php

直接宣告 $GLOBALS['xxx'],就可以直接在function裏頭使用了。

--

The $GLOBALS array can be used instead:

 

$GLOBALS['a'] = 'localhost';

function body(){

    echo $GLOBALS['a'];
}

 

From the Manual:

 

An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.

 

 

--

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()