why are there periods in php [duplicate]

2019-06-26 01:19发布

问题:

Possible Duplicate:
What does the 'period' character (.) mean if used in the middle of a php string?

as the title says, why are the periods? such as

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

obviously its because the variable is between strings, but shouldnt the quotes have taken care of that? Just want to know to clarify further coding

回答1:

In PHP, the period is the concatentation operator. Putting the periods in tells PHP to concatenate "mod/" to $modarrayout and then concatenate the resulting string to "/bar.php". See this page:

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



回答2:

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.



回答3:

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: http://php.net/manual/en/language.operators.string.php