为什么在PHP中存在句号

时间:2011-05-28 01:47:49

标签: php variables quote period

  

可能重复:
  What does the 'period' character (.) mean if used in the middle of a php string?

正如标题所说, 期间为何? 比如

require("mod/".$modarrayout."/bar.php"); 
显然它是因为变量在字符串之间,但引号不应该处理它吗? 只是想知道澄清进一步的编码

3 个答案:

答案 0 :(得分:6)

在PHP中,句点是连接运算符。将句点放入PHP会将"mod/"连接到$modarrayout,然后将结果字符串连接到"/bar.php"。见本页:

http://www.php.net/manual/en/language.operators.string.php

答案 1 :(得分:2)

在这种情况下,以下内容相同:

require("mod/$modarrayout/bar.php");

使用string concatenation是一种不同的字符串构建方法。

我建议阅读the manual page on strings

答案 2 :(得分:1)

有两个字符串运算符。第一个是连接运算符('。'),它返回其左右参数的串联。第二个是连接赋值运算符('。='),它将右侧的参数附加到左侧的参数。

阅读:http://php.net/manual/en/language.operators.string.php