看板 PHP 關於我們 聯絡資訊
※ 引述《jtorngl (煩死了啦!)》之銘言: : 剛開始學PHP,在變數的部份有個問題想請教先進 : 在函數中只能使用區域變數,無法使用全域變數 : 如果要在函數中使用全域變數可使用 : global 宣告、GLOBALS 陣列 : 想請問宣告為global和宣告為static有何差別? : Java的成員變數在類別內的方法也可使用 : 現在PHP多了一個global宣告突然腦袋打結了 <?php /* static */ function oh() { $a = 0; static $b = 0; echo 'a=' . $a++ . ' b=' . $b++ . '<br />'; } for( $i=0; $i<5; $i++) oh(); /* global */ $boo = 'PHP: Hypertext Preprocessor'; function boo() { global $boo; echo $boo; } boo(); ?> try it. -- The Internet: where men are men, women are men, and children are FBI agents. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.130.223.207