In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about what PHP developers tend to overlook. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Application skills of variables and arrays.
(1) an array function that is not used by many people. Foreach 、 list 、 each . If you give a few examples, you should be able to know. Example:
$data = array ('a'= > '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\ n ";}
(2) variable of function, variable of variable, "pointer" of variable: see the following example:
/ / variable $var = "this is a var"; $varname = "var"; echo $$varname; / / function variable function fun1 ($str) {echo $str;} $funname = "fun1"; $funname ("This is a function!");? >
The pointer to the variable. The pointer is enclosed in double quotation marks, indicating that it is not a real pointer. Look at the following example:
Function ($a) {$a + +;} $c = 0; function ($c); echo $c; / / $c is still 0 function (& $a) {$a + +;} $c = 0; echo $c; / / $c is 1? >
It is called "pointer" because it has the same function as pointer in C language. But this is not a real pointer, it can only be understood in this way.
2. Regular expression
Regular expressions are a very big problem, and Perl's regular expressions are famous for their power. And PHP is not weak, he inherited Perl's regular expression law, as well as his own set of rules. Here we only talk about PHP's own regular expressions. Regular expressions are the most basic elements. To put it simply, it is a set of rules that are used to determine whether other elements conform to their own rules, or whether they have the same feature description.
The regular expression begins with ^ and ends with $, with matching elements between the two symbols. If you check whether a phone number is for Beijing, use a regular expression to indicate that it is "^ 010 $". As long as the area code of the first three digits is 010, it is the number of Beijing, and the phone number behind it will be ignored. Then, use the regular expression matching function ereg to judge, for example:
$pattern = "^ 010 $"; $phone = "01080718828"; if (ereg ($pattern, $phone)) echo "number to Beijing"; else echo "not a number to Beijing";? >
This is the regular expression. All the phones in Beijing are 8 digits, so I need to know if this number is correct? What if he presses nine digits? If you judge right or wrong? This requires the character cluster of regular expressions. Then the regular expression of the above example should be written like this: ^ 010 [0-9] {8} $, you can also determine whether the number conforms to the rule. There are many applications of regular expressions, such as LBB, VBB Forum in the post of the so-called VBB code LBB code parsing, are done with regular expressions.
3. Template
Now that you know what regular expressions do, you can know the template. What is a template? Can you give me an example? Generally speaking, when a background program is used to write a web page, the program code is inserted into the web page. Such as PHP. This is a mix of HTML and PHP. The advantage is that the reading speed is fast, and the disadvantage is that if we work together to do the website, then non-programmers will not change the network.
With templates, the most rational division of labor can be achieved. The artist only does the page, the program only writes the background, and then comes back together. Excellent Jsp provides the function of custom tags and completes the template function very well. And how does the mainstream PHP do that? Is to use regular expressions to do this. You can download a PHPLIB from the Internet, in which there is a template.inc source code file in the PHP directory, that is, the class used to implement the template with PHP.
Thank you for reading! This is the end of this article on what PHP developers are easy to ignore. I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.