Is there any convention for naming php files?
Not talking about php class files, but files that are mostly HTML with some php inside them.
Should it be my-file-example.php
or myFileExample.php
or myfileexample.php
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Is there a way to play audio on a mobile browser w
There is no specific for the core php files you have to use your own naming convention, but you can name on the bases of you file work.
Like php file is only display the html then give
my_file_view.php
if it has database operation thenmy_file_db.php
and so on for the function and for other specification you can use it.
You'll come across packages using filenames as
(both containing classes with ClassName {})
(Personally, I use camelCase heavily for fnames, from var-habits i guess. )
I would suggest you to use underscore separators
my_file_example.php
, CodeIgniter for example use this convention for it's view files.With dashes, some IDE/Text Editor don't select all the filname by double clicking on it, while with underscore it select, generally, all the file name.
There is no definitive naming convention in PHP, and they can be differ by framework. If you don't use any framework u can use one of popular:
This table can be useful and tell you something more about naming convention (not only files but classes, methods and functions names):
Remember to being consistent with the naming convention.
There are usually 2 conventions you need to take into consideration:
In best scenario these 2 are the same. I usually try to avoid cases when a framework tries to force some custom rules.
Either way, the MOST important is to stay consistent throughout the project. Once you pick a convention to follow, stick with it until you start working on a different project. There's nothing worse than different naming conventions in a single project, doesn't matter if we're talking about files, classes, methods or whatever. Be consistent.
There is no really convention for PHP files.
You just should keep the same in your project.
I recommand you to use camelCase.