Variable naming should also comply with one of the following famous naming rules:
Famous variable naming rules
Camel notation
The first letter is lowercase, and the following letters all start with uppercase characters. For example:
var testValue = 0, secondValue = "hi" ;Pascal notation
starts with an uppercase letter, and all subsequent letters begin with an uppercase character. For example:
var TestValue = 0, SecondValue = "hi" ; Hungarian type notation
Appends a lowercase letter (or sequence of lowercase letters) before a variable named in Pascal notation to indicate the type of the variable. For example, i represents an integer and s represents a string, as shown below "
var iTestValue = 0, sSecondValue = "hi";
The following table lists some commonly used prefixes to make the sample code easier to read:
类型 |
前缀 |
示例 |
数组 |
a |
aValues |
布尔型 |
b |
bFound |
浮点型(数字) |
f |
fValue |
函数 |
fn |
fnMethod |
整型(数字) |
i |
iValue |
对象 |
o |
oType |
正则表达式 |
re |
rePattern |
字符串 |
s |
sValue |
变型(可以是任何类型) |
v |
vValue |
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