开发者

Why are there periods in PHP? [duplicate]

This question already has answers here: Close开发者_JAVA技巧d 11 years ago.

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


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:

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜