Home >Backend Development >PHP Tutorial >Examples of the essence and techniques in PHP language (1)_PHP Tutorial

Examples of the essence and techniques in PHP language (1)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:25:18909browse

Many PHP programmers, especially those who have not studied for a long time, do not know the essence of PHP. How did Perl become famous in the business world? Its powerful regular expressions. What about PHP? It is a language developed under Unix. Of course, it inherits many features of Perl and has the advantages of C. It is fast, concise and clear, especially for C programmers. PHP is their favorite. I just love "PHP" deeply (I have even forgotten my girlfriend). Here, I want to write about PHP variables and array application skills, PHP regular expressions, and PHP template applications. I will write about the complete combination of PHP and COM, and PHP and XML when I have time in the future.

1. Application skills of variables and arrays

(1) Array functions that are rarely used by many people. foreach, list, each. Just give a few examples and you should be able to figure it out. Example:

$data = array('a' => 'data1', 'b' => 'data2', 'c' => 'data3'); while(list($subscript, $value) = each($data)){echo "$subscript => $value :: ";echo "$subscript => $valuen";}reset($data);foreach($data as $subscript => $value){echo "$subscript => $value :: ";echo "$subscript => $valuen";}

(2) Variables of functions, variables of variables, “pointers” of variables:

    //变量的变量 $var = "this is a var";$varname = "var";echo $$varname;//函数的变量function fun1($str) {echo $str;}$funname = "fun1";$funname("This is a function !");?>

“pointers” of variables. 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仍为0function(&$a) {$a ++;}$c = 0;echo $c; //$c为1?>

The reason why it is called a "pointer" is because it has the same function as a pointer in C language. But this is not a real pointer, it can only be understood in this way. 1

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446685.htmlTechArticleMany PHP programmers, especially those who have not studied for a long time, do not know the essence of PHP. How did Perl become famous in the business world? Its powerful regular expressions. And what about PHP? He is a programmer from...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn