Home > Backend Development > PHP Tutorial > PHP coding standards (21)_PHP tutorial

PHP coding standards (21)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:20:20
Original
834 people have browsed it

8.3 Function

The method name is a verb, using mixed case. The first letter of the first word is lowercase, and the first letter of subsequent words is capitalized.
function run();
function runFast();
function getBackground();

Usually each method performs an action, so its naming should clearly indicate what it does: use checkForErrors() instead of errorCheck(), and use dumpDataToFile() instead of dataFile(). Doing so also makes functions and data more distinguishable objects.

Sometimes suffixes are useful:
Max - meaning the maximum value that can be assigned to an entity.
Cnt - The current value of a running count variable.
Key - key value.
For example: retryMax represents the maximum number of retries, and retryCnt represents the current number of retries.

Sometimes prefixes are useful:
is - meaning to ask a question about something. Whenever people see Is they know it's a problem.
get - means to get a value.
set - means setting a value
For example: isHitRetryLimit



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532583.htmlTechArticle8.3 The function method name is a verb, using mixed case, the first letter of the first word is lowercase, The first letter of subsequent words is capitalized. function run(); function runFast(); fun...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template