PHP Development Specification Manual of PHP code specification detailed _php Tips

Source: Internet
Author: User
Tags learn php php basics php website php website tutorial password protection
involves many aspects, such as PHP code specifications, PHP file naming code, Web site development process, Web site security and maintenance.
As the beginning of the PHP development specification, I from a pure PHP developer's point of view, I think that the PHP code specification, mainly from the PHP directory framework structure, PHP Code writing specifications, PHP file naming norms three angles to explain, I hope that the introduction of PHP to help learners.
Reasonable construction of PHP directory frame structure
We know that in the use of PHP site development before, we need to build the directory structure of the site, the Site Directory framework design reasonable norms, not only conducive to site development, but also to SEO, website promotion are good.
The general most basic PHP site structure involves pictures, CSS files, JS files, third-party components, management background and so on, the corresponding, the basis of the PHP directory framework structure also involved in these content, these directories are named when there are norms, such as
Photo catalog: Images or pic
CSS Catalog: CSS
JS Directory: JS
Third-party Components directory: Libs or include, the next level of directory can be defined according to the specific component name Directory name
Admin directory: Generally admin, Unit for security, you can set up a directory name or the admin Directory password protection. How do I set password protection for access directories?
Special reminder: For the Web site Framework directory structure, to do a good job in advance planning, in order to search engine friendly website promotion, the proposed directory structure level not too deep, level two or three directory structure can be.
In addition, if you adopt a template, you can create a template directory, such as the directory named TPL, if you use a Third-party template engine, such as smarty, you can decide whether to set a separate directory. PHP Basics Tutorial: Smarty Installation Tutorials
For a medium-sized website, you can also divide the site Directory framework according to the function of the website, such as according to the channel.
PHP file naming specification
Good PHP file naming code is also the key element of PHP development norms, help memory, easy to manage, PHP website program file naming also has certain rules, such as
PHP Web Home file naming code: index.php or Index.html
CSS file naming specification: The main CSS file is named Style.css, and you can also name specific modules or channels, such as CSS files for users, which can be defined as USER_STYLE.CSS or u_style.css
JS file naming specification: The main JS file named Main.js or major.js, other JS file naming, you can according to specific pages or specific objects named, such as the home page JS file can be named Index.js, service in the user login JS file can be named User_ Login.js and so on.
Web site configuration file naming specification: config.php or default_config.php, etc.
File naming Special reminders: In the name of the PHP file to consider portability, all use lowercase name, in addition to the name of the site directory, the file name can be used in two ways, a can be used to name specific documents, one can use simple and clear English word naming documents, do not arbitrarily named, Lead to future maintenance chaos.
PHP Code Writing specification
Good PHP code specification helps PHP starter learners benefit from your PHP code and help with your future code maintenance.
1, for the written PHP code, add the necessary code comments, while code comments to standardize, more basic PHP code writing specifications, please refer to the PHP Basic Grammar tutorial
2, Keep good PHP code writing specifications, reasonable use of indentation, keep the code beautiful.
3. Variable names, assignment characters, and values are separated by spaces using the assignment, i.e.
Copy Code code as follows:

?
$LEAPSOULCN = "Welcome to visit the PHP website tutorial network, this section mainly introduces PHP development standard PHP Code specification";
?>

4, when writing if, switch, function code, be sure to keep braces matching, that is
Copy Code code as follows:

?
if () {
......
}
?>

Or
Copy Code code as follows:

?
if ()
{
......
}
?>

5, named variable name or function name Note Code Writing specifications, you can use Pinyin, English words, abbreviations and other forms, the recommendation of English words as the PHP code naming norms, for more than two words of the following underlined connection or one of the words in the form of the first letter, that
Copy Code code as follows:

?
$web _name = "PHP website development Tutorial Network";
$WEBURL = "Http://www.jb51.net";
function Userlogin ()
{
}
?>

The above is the basic PHP code specifications for PHP beginners to learn PHP will help. Developing good PHP code specifications will benefit developers for a lifetime.
At this point, PHP Development Specification Manual of PHP code is introduced, a good Web site Framework directory building capacity, PHP file naming norms and PHP code writing norms need their own in the continuous development of accumulation and cultivation, and these development norms also contribute to the cooperation between partners, Help PHP Beginners Learn your PHP code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.