Php is a weak language. if there are many variables in the program, and many functions in PHP are named in disorder, they will be dazzled. Uniform coding style and even variable naming are very important in team development. I have been engaged in PHP development for many years. in order to make the team more efficient, I gradually formed a naming convention for PHP (some friends later said it was an existing Hungarian naming convention ), make your program look very clear. Next I will give you some experience, not necessarily applicable to others. php is a weak type language. if there are many variables in the program, and many PHP functions are very confusing, and then they will be dazzled.
Uniform coding style and even variable naming are very important in team development.
I have been engaged in PHP development for many years. in order to make the team more efficient, I gradually formed a naming convention for PHP (some friends later said it was an existing Hungarian naming convention ), make your program look very clear.
Next I will share my experience with you. it may not be applicable to others, but I will share it with you.
String, string type, add str before the variable
Copy the PHP content to the clipboard.
PHP code:
// The following variable is of the string type.
$ StrMessage = 'Hello World! ';
Array: array type. add a to the variable. one-dimensional arrays use singular nouns and multidimensional arrays use the plural words.
Copy the PHP content to the clipboard.
PHP code:
// The following variable is a one-dimensional array.
$ AData = array (1, 2, 3, 4, 5, 6 );
// The following variable is a multi-dimensional array.
$ AMembers = array ('id' => 123456, 'username' => 'ABC', 'Email '=> 'ABC # abc.com ');
Integer: an integer variable. add 'N' to the front'
Copy the PHP content to the clipboard.
PHP code:
// The following variable is an integer.
$ NCount = $ pBS-> Member-> getCount ();
Boolean: 'B' is added to the front of the boolean type'
Copy the PHP content to the clipboard.
PHP code:
// The following variable is Boolean.
$ BEncode = true;
Float, float type, add 'f' to the front'
Copy the PHP content to the clipboard.
PHP code:
// The following variable is floating point
$ FSave = 0.8; // off
Pointer type, such as class. Add 'P' to the front'
Copy the PHP content to the clipboard.
PHP code:
// The following is the instantiation of a class
$ PBP = new BluePage;
Resource, resource type. add 'Rs 'to the front'
Copy the PHP content to the clipboard.
PHP code:
$ RsConn = MySQL_connect ('localhost', 'user', 'pw ');
$ RsHandle = fopen ($ strFilename );
Unknown variable, using mx
Copy the PHP content to the clipboard.
PHP code:
$ MxData = getData ();
User-defined function, starting with fn _
Copy the PHP content to the clipboard.
PHP code:
Function fn_HaltError ($ strErrorMessage)
{
// Do something...
}
A comprehensive example (using paging classes ):
Copy the PHP content to the clipboard.
PHP code:
Include ("lib/BluePage. class. php ");
$ PBP = new BluePage;
$ RsConn = mysql_connect ('localhost', 'root', '000000') or die (mysql_error ());
Mysql_select_db ('test', $ rsConn );
$ StrQuery = "select count ('id') FROM test ";
$ NCount = $ pBP-> myGetCount ($ strQuery, $ rsConn); // obtain the total number
If ($ nCount <1)
{
Fn_HaltError ($ aMessages ['nodata']);
}
$ NShowNum = 10;
// Pagination array and html
$ APDatas = $ pBP-> get ($ nCount, $ nShowNum );
$ StrHtml = $ pBP-> getHTML ($ aPDatas );
// The page data contains offset, and the data is retrieved.
$ StrQuery = "SELECT * FROM test LIMIT". $ aPDatas ['offset']. ",". $ nShowNum;
$ RsResult = mysql_query ($ strQuery );