为什么 PHP 中有句点?
为什么下面的代码中包含句点?
require("mod/" . $modarrayout . "/bar.php");
显然,这是因为变量位于字符串之间,但引号不应该解决这个问题吗? PHP
Possible Duplicate:
What does the 'period' character (.) mean if used in the middle of a php string?
Why are the periods included in the code that follows?
require("mod/" . $modarrayout . "/bar.php");
Obviously, it's because the variable is between strings, but shouldn't the quotes have taken care of that?
PHP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 PHP 中,句点是连接运算符。添加句点会告诉 PHP 将
"mod/"
连接到$modarrayout
,然后将结果字符串连接到"/bar.php"
。请参阅页面字符串运算符。In PHP, the period is the concatenation operator. Putting the periods in tells PHP to concatenate
"mod/"
to$modarrayout
and then concatenate the resulting string to"/bar.php"
. See page String Operators.在这种情况下,以下内容是相同的:
使用 字符串连接 是不同的构建字符串的方法。
我建议阅读字符串手册页。
The following is the same in this case:
Using string concatenation is a different approach to string building.
I suggest reading the manual page on strings.
有两个字符串运算符。第一个是串联运算符(“.”),它返回右参数和左参数的串联。第二个是连接赋值运算符('.='),它将右侧的参数附加到左侧的参数。
阅读:字符串运算符
There are two string operators. The first is the concatenation operator ('.'), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator ('.='), which appends the argument on the right side to the argument on the left side.
Read: String Operators