Home > Backend Development > PHP Tutorial > Personal summary of PHP coding standards_PHP tutorial

Personal summary of PHP coding standards_PHP tutorial

WBOY
Release: 2016-07-14 10:12:05
Original
942 people have browsed it

1. At the head of the original code or class, indicate the author and key algorithm calculation process
For example
/**
*@author zengmoumou
*Function: According to the list IP, obtain the operator, province, city, and county corresponding to the IP
*/
2. Try to use a combination of English words for variables, with the first one lowercase and the last one capitalized
For example:
$confTreeModel = D("ConfTree");
3. Try to use a combination of English words for function names, with the first one lowercase and the last one capitalized
For example:
function searchRealServer($keyword)
4. It is best to write the author, variables, and algorithm of the function above the function
For example:
/**
* @author zengmoumou
* Get the searched result switch
* Enter description here ...
* @param unknown_type $allIds
​​*/
Private function getSwitchsInIds($allIds) {
5. Try not to exceed 100 lines of function. If it exceeds, split it as appropriate


6. Independent functional original code is best divided into configuration page, function page and business page.
For example, a small development that reads the database and does summary.
Can be split into
config.php configuration page [Write database configuration, etc.]
function.php Function page [Write various functions with independent functions, such as reading data functions, constructing report functions, and sending email functions]
statWeekData.php business page [refer to the configuration page, function page, and call various functions in order to process the business logic]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477239.htmlTechArticle1. At the head of the original ecological code or class, indicate the author and key algorithm calculation process, such as /** * @author zengmoumou *Function: According to the list ip, get the operator, province, city, county corresponding to the ip...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template