$var和$var之间的差异=


Difference between $var and $var.=

$var=$var.=之间有什么区别?

我无法理解以下陈述之间的区别:

$querypost .= "&showposts=$limit";
$querypost .= "&paged=$paged";

这是连接字符串,例如

$querypost = 'a';
$querypost = 'b'; // $querypost holds string 'b' now, 
                  // it will override the previous value

$querypost = 'a';
$querypost .= 'b'; // $querypost holds 'ab' now

如果你想要一个友好的解释,可以把.看作一种粘合剂,它将两个字符串粘在一个变量中,而不是覆盖前面的字符串。

在您的情况下,查询是串联的,通常当查询字符串很大时,程序员会这样做,或者当表单具有可选参数时,它们通常是串联的。。。

查看差异

<?php
$testing = "Test ";
$testing  = "file"; 
//if we print `$testing` output is `file` $testing overriding the previous value

$testing = "Test ";
$testing  .= "file";     
//if we print `$testing` output is `Test file`. because **.** is a concatenate the previous value
?>

例如查询

$query  = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
  $var = "a"; ////results var is no a
  $var .= "b" ////results var is now ab .= is equal to concatanation of variable or string.