也就这样, - 变量的作用域 的评论 https://type.so/python/variable.html zh-CN php的变量作用范围$str = 'something'; function infunction() { echo $str; //报错 } function infunc() { ... Wed, 01 Feb 2012 10:13:51 +0800 Wed, 01 Feb 2012 10:13:51 +0800 konakona https://type.so/python/variable.html/comment-page-1#comment-3274 https://type.so/python/variable.html/comment-page-1#comment-3274 Wed, 01 Feb 2012 10:13:51 +0800 konakona 哈哈~樓主的博客樣式我非常喜歡,特別是代碼提示這段的design!
=w= 不過PHP的變量作用域你可以理解為全局變量和區域變量。是比其他語言好理解的。
在一個方法/函數里的變量是區域變量,不可以被外部使用。反之亦然。
如果一定要用,可以用global $str;声明,但这是非常不推荐的做法。

]]>
https://type.so/python/variable.html/comment-page-1#comment-3274#comments
fc_lamp https://type.so/python/variable.html/comment-page-1#comment-72 https://type.so/python/variable.html/comment-page-1#comment-72 Fri, 16 Dec 2011 13:30:13 +0800 fc_lamp 哈哈。。。这仁兄说的太可爱了。。

]]>
https://type.so/python/variable.html/comment-page-1#comment-72#comments
小子欠扁 https://type.so/python/variable.html/comment-page-1#comment-52 https://type.so/python/variable.html/comment-page-1#comment-52 Tue, 29 Nov 2011 09:30:07 +0800 小子欠扁 这不是还没写完吗

]]>
https://type.so/python/variable.html/comment-page-1#comment-52#comments
小松 https://type.so/python/variable.html/comment-page-1#comment-51 https://type.so/python/variable.html/comment-page-1#comment-51 Mon, 28 Nov 2011 19:13:29 +0800 小松 尼玛,你这是毛文章啊?

]]>
https://type.so/python/variable.html/comment-page-1#comment-51#comments