与其内容有关的变量命名约定
我知道有无数与公约有关的问题。然而,关于一些在编码中一直困扰我的细节,我找不到太多东西。
它归结为文件系统和设备表示,无论是句柄/资源还是路径;通常遵循哪些约定来正确命名包含此类值/数据的变量?
更具体地说,我的意思是:
/path/to/resource/
目录路径 > ($dirpath
)(句柄)
文件句柄/资源 ($filehandle
)filename.php
文件名 ($filename
)/path/to/resource/filename.php
文件路径 ($filepath
)
如果以上内容如有不正确之处,请指教;对此的担忧可能看起来很愚蠢,但我想确保自己能够理解,更不用说未来的同事了。
任何有关参考资料/完整列表的指示,或来自您个人经验的建议都非常受欢迎。
(将其标记为 PHP,以防有我应该知道的任何语言特定约定)
I understand there's gazillions of questions pertaining to conventions. I couldn't find much, however, regarding some specifics that have always plagued me in my coding.
It comes down to filesystem and device representations, whether a handle/resource or path; what conventions are often followed to appropriately name variables containing such values/data?
More specifically I mean:
/path/to/resource/
A directory path ($dirpath
)(handle)
A file handle/resource ($filehandle
)filename.php
A file name ($filename
)/path/to/resource/filename.php
A file path ($filepath
)
If any of these are incorrect, please advise; concern over this may seem asinine, however I want to secure the understanding for myself, not to mention future colleagues.
Any directions to references/complete lists, or suggestions from your personal experience are more than welcome.
(marked it as PHP in case there are any language specific conventions I should know)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在那里使用了相当标准的变量名称,所以我认为任何 php 程序员都不会将它们误认为是其他名称。
You're using pretty standard variable names there, so I don't think any php programmer would mistake those for something else.