why are there periods in php [duplicate]

余生颓废 提交于 2019-12-10 17:12:35

问题


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



来源:https://stackoverflow.com/questions/6159172/why-are-there-periods-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!