本文介绍了PHP串联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用某些PHP,但似乎无法弄清楚以下内容。
I am trying to get into some PHP and I can't seem to figure out the following.
我可以使用串联的PHP创建字符串:
I can create a string by means of PHP with concatenation:
echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
但是如果您想使用变量来做呢? (我猜想WP的功能可以称为变量。)我在这里很迷茫。以下操作无效。或至少是我的文本编辑器抛出未知错误。
But what if you want to do this with a variable? (I am guessing WP's functions can be called variables.) I am quite lost here. The following does not work. Or at least, my text editor throws an unknown error.
<?php
if ( is_404() ) {
echo "<script src='" . get_stylesheet_directory_uri(); . "/sm/script/soundmanager2-nodebug-jsmin.js'></script>
<script>
soundManager.setup({
url: '" . get_stylesheet_directory_uri(); . "/sm/swf/',
onready: function() {
var mySound = soundManager.createSound({
id: 'aSound',
url: 'http://www.mysite.com/sound.mp3',
volume: '25'
});
mySound.play();
},
ontimeout: function() {
}
});
</script>"
}
?>
推荐答案
在这里出错:
rc='" . get_stylesheet_directory_uri(); . "/s
句子中间有;
。同样在字符串的末尾,您没有;
You have a ;
in the middle of your sentence. Also at the end of your string you don't have a ;
正确的语法
<?php
if ( is_404() ) {
echo "<script src='" . get_stylesheet_directory_uri() . "/sm/script/soundmanager2-nodebug-jsmin.js'></script>
<script>
soundManager.setup({
url: '" . get_stylesheet_directory_uri() . "/sm/swf/',
onready: function() {
var mySound = soundManager.createSound({
id: 'aSound',
url: 'http://www.mysite.com/sound.mp3',
volume: '25'
});
mySound.play();
},
ontimeout: function() {
}
});
</script>";
}
?>
这篇关于PHP串联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!