Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否有一个JavaScript等价于;字符串"&引用;“字符串”;在PHP中?_Javascript_Php_Concatenation_String Concatenation - Fatal编程技术网

是否有一个JavaScript等价于;字符串"&引用;“字符串”;在PHP中?

是否有一个JavaScript等价于;字符串"&引用;“字符串”;在PHP中?,javascript,php,concatenation,string-concatenation,Javascript,Php,Concatenation,String Concatenation,我目前正在学习一点JavaScript,并提出了一个问题 在PHP中,我习惯于用一个简单的点将文本和字符串绑定在一起,如下所示: echo "Text" . $String . "anotherText" . $anotherString 这在JavaScript中可能吗?(不是回音,而是字符串和文本的绑定。)是的,添加: 'Text' + str + 'anotherText' + anotherString; 在JavaScript中,它是+而不是 示例1: document.writ

我目前正在学习一点JavaScript,并提出了一个问题

在PHP中,我习惯于用一个简单的点将文本和字符串绑定在一起,如下所示:

echo "Text" . $String . "anotherText" . $anotherString
这在JavaScript中可能吗?(不是回音,而是字符串和文本的绑定。)

是的,添加:

'Text' + str + 'anotherText' + anotherString;


在JavaScript中,它是
+
而不是

示例1:

document.write("Text" + somestring + "anotherText" + anotherString);
alert("Text" + somestring + "anotherText" + anotherString);
var john = "Text" + somestring + "anotherText" + anotherString;
示例2:

document.write("Text" + somestring + "anotherText" + anotherString);
alert("Text" + somestring + "anotherText" + anotherString);
var john = "Text" + somestring + "anotherText" + anotherString;
示例3:

document.write("Text" + somestring + "anotherText" + anotherString);
alert("Text" + somestring + "anotherText" + anotherString);
var john = "Text" + somestring + "anotherText" + anotherString;

我认为
document.write
是不必要的
document.write
或多或少相当于PHP中的
echo
的JavaScript。只需搜索一下提示:>
dot operator PHP
应该会导致术语串联->
JavaScript串联
就会找到答案。