在相等运算符之前对连接的困惑

时间:2014-11-22 13:34:39

标签: php concatenation

我正在阅读关于分页的教程,我很困惑为什么在一个区域放置连接点,我认为这是不必要的,并认为我教程视频的海报会出错,但他们没有... .so当我实现代码并且它工作正常但作为测试我删除了连接并且代码没有按预期工作。

这是代码。

我用来连接看起来像这样

$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;

但在教程的下方,连接在=运算符

前面看起来像这样
$list = '';
$list .='<a href="testpage.php?id='.$username.'">' .$into. '</a>Click Here'

感谢您给出的任何解释

2 个答案:

答案 0 :(得分:2)

串联前和等号可以称为'追加'

例如

$a="hello";
$a.=" world";
echo $a;

结果将是 - hello world

答案 1 :(得分:1)

$list .='<a href="testpage.php?id='.$username.'">' .$into. '</a>Click Here'

就像

$list =$list.'<a href="testpage.php?id='.$username.'">' .$into. '</a>Click Here'

就像+=运算符

一样

最好在发布问题之前搜索您的问题

参考Here