PHP programmers generally ignore some of the essence (collection)

xiaoxiao2021-03-06  41

1. Variables, and arrays Application Skills (1) Many people use a lot of array functions. Foreach, List, Each. Take a few examples, you should know. Example: 'DATA1', 'B' => 'DATA2', 'C' => 'DATA3'); While (List ($ Subscript, $ VALUE) = Each ($ data)) {echo "$ subscript => $ value ::"; echo "$ subscript => $ value / n

RESET ($ DATA); Foreach ($ DATA AS $ Subscript => $ VALUE) {Echo "$ subscript => $ value ::"; echo "$ subscript => $ value / n
";} (2) The variable of the function, the variable of the variable, the "pointer" of the variable: Look at the example: The "pointer" of the variable. This pointer plus double quotes indicating that he is not a real pointer. See the case: The reason why it is "pointer" is because he has the same functionality as the pointer in the C language. But this is not a real pointer, which can only be such a understanding.

2. Regular expression regular expressions are a very large topic, and the power of Perl's regular expression is smelling. PHP is not weak, he inherits the regular expression rule of Perl, and has its own set of rules. Here is just PHP's own regular expressions. Regular expressions are the most basic elements. Simply put in a set of rules, it is used to determine that other elements are not in line with their own rules, or have the same feature description. The rules of the regular expression: ^, end $, which are matched between the two symbols. If you check a phone number, it is called to Beijing, and the regular expression is "^ 010 $". As long as the first 3-bit area number is 010, it is the number of Beijing, and the phone number behind will not take it. Then, use the regular expression match function EREG to determine, example: This is the regular expression. Beijing's phone is 8 digits, then I want to know if this number is correct? If he pressed 9-digit? If it is determined? This is to use the character cluster of the regular expression. Then the regular expression of the above case is to write this: ^ 010 [0-9] {8} $, you can simultaneously determine the number if it meets the rules. Regular expressions have a lot of applications, like the LBB, the VBB Forum on the so-called VBB code LBB code is completed with regular expressions. 3, the template knows the function of the regular expression, then you can know the template. What is a template? What is it? General Write the web page to insert the program code in the web page. Such as PHP. This is HTML and PHP mixed. Such an advantage is that the read speed is fast, and the disadvantage is that if the partnership cooperate to be a website, the non-programmer will not change. The template can be used to reach the most rationalization of the division. The art only does the page, the program only writes the background, and then together. Excellent JSP provides custom labels to complete the template feature. How does the mainstream PHP do? It is done by using regular expressions. You can download a phpLib on the Internet, there is a template.inc's source code file in the PHP directory, which is a class with PHP implementation template.

转载请注明原文地址:https://www.9cbs.com/read-69052.html

New Post(0)