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

PHP coding standards (21)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:20:20806browse

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:
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