For children's shoes who are getting started with PHP, learning about PHP Development specifications can take a lot of detours, and there are also a lot of PHP Development specifications on the Internet. I will use PHP in combination with my own situation, the PHP development specifications I understand involve multiple aspects, such as PHP code specifications, PHP file naming rules, website development processes, and website security and maintenance. For children's shoes who are getting started with PHP, learning about PHP Development specifications can take a lot of detours, and there are also a lot of PHP Development specifications on the Internet. I will use PHP in combination with my own situation, the PHP development specifications I understand involve multiple aspects, such as PHP code specifications, PHP file naming rules, website development processes, and website security and maintenance.
As the beginning of the PHP development specification, I refer to what I think is the PHP code specification from the perspective of a pure PHP developer, this article mainly describes the PHP Directory framework structure, PHP code writing specifications, and PHP file naming rules, hoping to help PHP beginners.
Reasonably construct the PHP Directory framework structure
We know that before using PHP for website development, we need to build the directory structure of the website. The website Directory framework structure is properly designed and standardized, which is not only conducive to website development, but also for SEO, website promotion is beneficial.
Generally, the most basic PHP website structure involves images, CSS files, JS files, third-party components, and Management backend. correspondingly, the basic PHP Directory framework structure also involves such content, these directories are also standardized, such
Image Directory: images or pic
CSS Directory: css
JS Directory: js
Third-party component directory: libs or include. the directory name can be defined based on the specific component name in the next level.
Management Directory: admin is used generally. for security reasons, you can set a new directory name or set password protection for the admin directory. How do I set password protection for access directories?
Special reminder: Plan the directory structure of the website framework in advance. in order to be friendly to search engines and facilitate website promotion, we recommend that you do not have to make the directory structure level too deep. you can use the Level 2 and Level 3 directory structure.
In addition, if you use a template, you can create a template directory, such as naming the directory as tpl. if you use a third-party template engine, such as smarty, you can decide whether to set a directory as needed. PHP basic tutorial: Smarty installation tutorial
For medium-sized websites, you can also divide the website Directory framework structure based on the website functions, such as by channel.
Php file naming rules
A good PHP file naming convention is also an element of PHP Development specifications, which helps to remember and facilitate management. PHP website program files also have certain naming rules, such
PHP homepage file naming rules: index.phpor index.html
CSS file naming rules: CSS
JS file naming rules: the main JS file is named main. js or major. js. you can name other JS files based on specific pages or specific objects. for example, the JS file on the homepage can be named index. js. the JS file used for user login can be named user_login.js.
Naming rules for website configuration files: config. php or default_config.php
Special file naming reminder: When naming php files with portability in mind, please use lower-case names. In addition, like the website directory name, you can use either of the following methods to name files, A specific file can be named in pinyin, and a simple and clear English word naming file can be used. do not name it casually, resulting in confusion in future maintenance.
PHP code writing specifications
A good PHP code specification helps beginners of PHP to benefit from the PHP code you write and facilitate code maintenance in the future.
1. add necessary code comments for the written PHP code, and standardize the code comments. for more basic PHP code writing standards, see The PHP basic syntax tutorial.
2. maintain good PHP code writing specifications, use indentation properly, and keep the code beautiful.
3. when the value assignment operator is used, the variable name, value assignment operator, and value are separated by spaces, that is
1 2 3
|
$ Leapsoulcn = "Welcome to the PHP website tutorial network. this section mainly introduces PHP code specifications in PHP development specifications "; ?> |
4. when writing if, switch, and function code, make sure that the braces match, that is
Or
5. pay attention to code writing specifications when naming variable names or function names. you can use pinyin, English words, abbreviations, and other forms. we recommend that you use English words as PHP code naming rules, the following dashes of two or more words are connected or the first letter of one word is capitalized, that is
1 2 3 4 5 6 7 8 9 10
|
$ Web_name = "PHP website development tutorial Network ";
$ WebUrl = "http://www.leapsoul.cn ";
Function userLogin () {
} ?> |
The above is the basic PHP code specification, which will be helpful for PHP beginners to learn PHP. Developing a good PHP code specification will benefit developers for a lifetime.
So far, PHP code specifications in the PHP development specification manual have been introduced, good website framework directory construction capabilities, PHP file naming rules, and PHP code writing specifications need to be accumulated and developed in constant development. at the same time, these development specifications are also conducive to cooperation between partners, help PHP beginners learn your PHP code.