在php中$_foo
和_foo
有什么区别?
2
A
回答
8
一是指一个名为_foo
variable。第二个是指名为_foo
的global constant。当您试图访问一个未定义的变量或undefined constant
默认情况下PHP会发出低严重错误。在这种情况下,变量的“值”将假定为null
,而常量的“值”将被假定为其名称的字符串化版本 - 在此例中为'_foo'
。
-1
变量前面有美元符号($)。在一个方法之前的下划线(没有美元符号)表示它是受保护的,双下划线表示它是私人的,它们不能被外部调用。
+0
这里解释:[http://php.net/manual/en/language.oop5.magic.php](http://php.net/manual/en/language.oop5.magic.php) – Dorian 2012-08-14 14:25:17
相关问题
- 1. @synthesize foo = _foo是什么?
- 2. $(())和expr之间的区别是什么?
- 3. ++和:haskell之间的区别是什么?
- 4. $(...)和`...`之间的区别是什么
- 5. [undefined]和[,]之间的区别是什么?
- 6. 区别:%% a和%variable%变量之间的区别是什么?
- 7. .php和.php.inc文件扩展名之间的区别是什么?
- 8. “*”和“?”之间的区别是什么?在PHP preg比赛?
- 9. Python和PHP之间的主要区别是什么?
- 10. PHP - date_timestamp_get(date_create())和time()之间的区别是什么?
- 11. TVF/UDF之间的区别是什么
- 12. “;”和“;”之间的区别是什么?和T-SQL中的“GO”?
- 13. MVC和MVVM之间的区别和相似之处是什么?
- 14. [EmailPasswordAuthProvider,EmailAuthProvider]之间的区别是什么
- 15. undefined和null之间有什么区别?
- 16. url.getFile()和getpath()之间有什么区别?
- 17. gets()和getc()之间有什么区别?
- 18. UIModalTransitionStyle和UIModalPresentationStyle之间有什么区别?
- 19. $ .cache和$ .data之间有什么区别?
- 20. System.Workflow.ComponentModel.activity和System.activities.activity之间有什么区别
- 21. {0}和+之间有什么区别?
- 22. @dynamic和@synthesize之间有什么区别?
- 23. vbNullString和“”之间有什么区别吗?
- 24. $ {}和#{}之间有什么区别?
- 25. typedef和宏之间有什么区别?
- 26. spark.jars和spark.driver.extraClassPath之间有什么区别
- 27. Lazy.Force()和Lazy.Value之间有什么区别
- 28. makeFirstResponder和becomeFirstResponder之间有什么区别?
- 29. CFUrl和NSUrl之间有什么区别
- 30. Data.Datatable和System.Data.Datatable之间有什么区别?
一个是变量,另一个是“假定”是一个常量。你为什么问这个问题? – Matt 2012-08-14 14:13:28