PHP has been quickly promoted with ease of use, but it does not mean that it can be used well. In fact, many programmers use it to easily establish a WEB application system, but how many people have carefully considered their code, whether it is easy to protect, whether it is hard enough for PHP to get agile promotion for its ease of use, but it is not easy to say that it can be used well, in fact, many programmers use it to easily establish a WEB application system, but how many people have carefully considered their code, whether it is easy to protect, whether it is tough enough, whether it is efficient enough, whether it is safe enough, when PHP is used to build a large website, these are very important factors. Next we will discuss from the beginning of the title to some fatal errors. It is divided into three parts.
The first part is slightly incorrect.
I. Printf (),
This function is used to display data in a pattern. It is used only when you need to change the display pattern of a data.
For example, the PI (3.1415926) value is displayed with different precision.
/*
* The three faces of attributes
*/
Printf ('Pi is: %. 2fn
N', M_PI );
Printf ('Pi is also: %. 3fn
N', M_PI );
Printf ('Pi is also: %. 4fn
N', M_PI );
?>
However, many programmers only apply this function to display some variable values and function return values. Because Printf () requires a pattern of the data before displaying the data at a slow speed, print and echo are used only for data display to increase the speed.
II. Semantic check
PHP is a weak language, that is, it does not need to be defined before applying a variable. This makes programming very convenient and mobile, however, you must know which type the variable should be. because the variable still corresponds to a certain type at runtime (various types can be freely converted to each other ), a variable of no type does not exist. It is possible that PHP cannot check your semantic errors. However, changes to the variable type may lead to the creation of some ambush titles. Another noteworthy title is the scope of variables, which may also lead to the generation of some ambush titles.
PHP has the following basic variables:
Boolean, resource, integer, double, string, array and object.
III. Application of temporary variables
Misuse of temporary variables may lead to a decrease in program running efficiency. When to apply temporary variables can be based on the following two considerations:
1. whether the variable is applied at least twice.
2. Will the application of this variable significantly improve the readability of the program.
If one does not meet the requirements, the application of the variable is omitted. For example:
$ Tmp = date ('F d, h: I a');/* ie January 3 */
Print $ tmp;
?>
It should be changed:
Print date ('F d, h: I ');
?>
Another example:
// String reverse_characters (string str)