0514-86177077
9:00-17:00(工作日)
案例
?php function test(){ $a=10; echo $a; } test(); echo "hr />"; echo $a; ?>
案例結果
?php $a=10; function test(){ echo $a; } test(); echo "hr />"; echo $a; ?>
案例:聲明方式 global
?php $a = 10; function test(){ global $a; echo $a; } test(); ?>
案例:常量
?php define("NAME","WCP"); function test(){ echo NAME; } test(); ?>
?php function test(){ static $a = 0; echo ++$a."|"; } test(); test(); test(); ?>
到此這篇關于PHP變量的作用范圍的文章就介紹到這了,更多相關PHP變量的作用范圍內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!
標簽:北京 孝感 日照 濟源 阿里 那曲 哈密 池州
上一篇:PHP設計模式之命令模式示例詳解
下一篇:php swoft框架實例用法
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8