The following articles will be shared by developers who concentrate some PHP notes. I have found many PHP (PHP training tutorials) programmers, especially those who have not studied php for a long time, I do not know the essence of PHP. How did Perl become famous in the business world? Its powerful regular expression. What about PHP? He is a language developed from Unix, and of course inherits many features of Perl, while at the same time concentrating some of the essence of PHP notes
I would like to share with you the following articles;
I found that many PHP (PHP Training php tutorials) programmers, especially those who have not studied PHP for a long time, do not know the essence of PHP. How did Perl become famous in the business world? Its powerful regular expression. What about PHP? He is a language developed from Unix. of course, he inherits many features of Perl and has advantages in C. Fast, concise, and clear. especially for C programmers, PHP is a favorite. I love php and forget my girlfriend :)). Here, I want to write an article about PHP variables, array application skills, PHP regular expressions, and PHP template applications. I will try again later to write the full combination of PHP, COM, PHP, and XML.
1. Techniques for applying variables and arrays (1) array functions that are rarely used. Foreach, list, and each. Here are a few examples. 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 ::"; echo "$ subscript => $ value \ n ";}
(2) function variables, variable variables, and variable "pointer": 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" of the variable ". This pointer is enclosed in double quotes, indicating that it is not a real pointer. Take a 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 the pointer in C language. But this is not a real pointer. it can only be understood in this way.
2. Regular expressions regular expressions are a very big question. Perl's strong regular expressions are famous. PHP is not weak. it inherits the regular expression rules of Perl and has its own set of rules. Here we only talk about PHP regular expressions.
Regular expressions are the most basic elements. Simply put, it is a set of rules used to determine whether other elements comply with their own rules, or whether they have the same feature description.
The starting character of the regular expression: ^, ending Character $. The two symbols are matched elements. If you check whether a phone number is sent to Beijing, use a regular expression to indicate "^ 010 $ ". As long as the first three area codes are 010, that is, the Beijing Number, the phone number at the end will be no longer needed. Then, use the regular expression to match the ereg function. for example:
$ Pattern = "^ 010 $"; $ phone = "01080718828"; if (ereg ($ pattern, $ phone) echo "call to Beijing "; elseecho "not the number to Beijing";?>
This is a regular expression. The numbers in Beijing are 8 digits. Do I need to know if this number is correct? What if he presses the 9-digit number? If it is true or false? This requires the use of regular expressions in character clusters. In the above example, the regular expression should be written as follows: ^ 010 [0-9] {8} $ to determine whether the number meets the rules at the same time. Regular expressions have many applications, such as the parsing of the so-called VBB code LBB code in the LBB and VBB forums.
3. the template knows the regular expression function, so you can know the template. What is a template? For example? When a webpage is used as a background program, the program code is inserted into the webpage. Such as PHP. This is the hybrid writing of HTML and PHP. This advantage is that the reading speed is fast, and the disadvantage is that if you work together to build a website, non-programmers will not change the network.
With templates, the most reasonable division of labor can be achieved. The artist only serves as the page, and the program only writes to the background, and then combines them. Excellent Jsp provides the custom tag function to complete the template function. How does the mainstream PHP achieve this? This is done using regular expressions. You can download a PHPLIB file from the internet. The PHP directory contains a source code file of template. inc, which is the class used to implement template application using PHP.
Due to the limited space, I just want to talk about the content here. if you really want to learn it, please read the special teaching materials. If you want to clarify the regular expression, you can write a small book.
We can acquire real knowledge through continuous learning, never satisfy the current knowledge, and keep forging ahead is fundamental. this is also true in the world of programming, I like to get new knowledge. I hope you will get the same new knowledge. there is no end to learning !!!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service