Home >Backend Development >PHP Tutorial >Systematic summary of the essence and skills in PHP development language_PHP tutorial

Systematic summary of the essence and skills in PHP development language_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:56:50944browse

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');
      $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

  ";

  }

while(list($subscript, $value) = each($data))

 {

      //变量的变量

  $var = "this is a var";

  $varname = "var";

  echo $$varname;

  //函数的变量

  function fun1($str) {

  echo $str;

  }

  $funname = "fun1";

  $funname("This is a function !");

  ?>

echo "$subscript => $value :: ";

     function($a) {

  $a ++;

  }

  $c = 0;

  function($c);

  echo $c; //$c仍为0

  function(&$a) {

  $a ++;

  }

  $c = 0;

  echo $c; //$c为1

  ?>

echo "$subscript => $valuen
  •  ";
  •  }
  • reset($data);
  • foreach($data as $subscript => $value)
  •  {
echo "$subscript => $value :: ";

echo "$subscript => $valuen

 }
(2) Function variables, variables of variables, and "pointers" of variables:
//Variable variables  $var = "this is a var";  $varname = "var"; echo $$varname; //Function variables 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  ?>
The reason why it is called a "pointer" is 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. Total 2 pages: Previous page12Next page http://www.bkjia.com/PHPjc/364182.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364182.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