是否有任何命名PHP文件的约定?
不是在谈论PHP类文件,而是大多数HTML文件,其中包含一些PHP.
应该是my-file-example.PHP还是myFileExample.PHP或myfileexample.PHP?
最佳答案
PHP中没有明确的命名约定,它们可能因框架而异.如果你不使用任何框架,你可以使用一个流行的:
原文链接:https://www.f2er.com/html/426275.html> with_underscores
> PascalCased
> camelCased
这个表很有用,并告诉你更多关于命名约定的信息(不仅是文件,还有类,方法和函数名称):
╔═══════════════════════╦═════════════╦════════════╦══════════════╦════════════╦════════════╗
║ PHP Project ║ Classes ║ Methods ║ Properties ║ Functions ║ Variables ║
╠═══════════════════════╬═════════════╬════════════╬══════════════╬════════════╬════════════╣
║ Akelos Framework ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ CakePHP Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ CodeIgniter Framework ║ Proper_Case ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Concrete5 CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Doctrine ORM ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ Drupal CMS ║ PascalCase ║ camelCase ║ camelCase ║ lower_case ║ lower_case ║
║ Joomla CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ modx CMS ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ lower_case ║
║ Pear Framework ║ PascalCase ║ camelCase ║ camelCase ║ ║ ║
║ Prado Framework ║ PascalCase ║ camelCase ║ Pascal/camel ║ ║ lower_case ║
║ SimplePie RSS ║ PascalCase ║ lower_case ║ lower_case ║ lower_case ║ lower_case ║
║ Symfony Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
║ wordpress CMS ║ ║ ║ ║ lower_case ║ lower_case ║
║ Zend Framework ║ PascalCase ║ camelCase ║ camelCase ║ camelCase ║ camelCase ║
╚═══════════════════════╩═════════════╩════════════╩══════════════╩════════════╩════════════╝
请记住与命名约定保持一致.