gpt4 book ai didi

templates - 为什么 Magento 中的局部变量有一个下划线前缀?

转载 作者:行者123 更新时间:2023-12-04 18:23:42 24 4
gpt4 key购买 nike

作为后续 an earlier question我想知道是否有人知道为什么 Magento 模板都用下划线声明它们的变量。模板是 .phtml 文件 include -ed 来自 Mage_Core_Block_Template::fetchView() ,它们的局部变量在函数结束时被处理掉,永远不会变成全局变量。

那么下划线有什么意义呢?

最佳答案

我认为是尊重采埃孚的命名约定:

http://framework.zend.com/manual/en/coding-standard.naming-conventions.html#coding-standard.naming-conventions.variables

For instance variables that are declared with the "private" or "protected" modifier, the first character of the variable name must be a single underscore. This is the only acceptable application of an underscore in a variable name. Member variables declared "public" should never start with an underscore.

关于templates - 为什么 Magento 中的局部变量有一个下划线前缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3949202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com