PHP echo脚本不起作用

时间:2013-06-05 10:53:08

标签: php echo

所以我在网站上有背景音乐,如果页面上有视频,我会尝试让音乐暂停,但是当我尝试echo脚本时,我的嵌入式视频就会消失。我在这一点上有点迷失:

<?php
$url = 'http://www.youtube.com/watch?v=4PzOqCpxyEU';
preg_match(
    '/[\\?\\&]v=([^\\?\\&]+)/',
    $url,
    $matches
);
$id = $matches[1];

$width = '640';
$height = '385';
echo '<object width="' . $width . '" height="' . $height . '"><param name="movie"      value="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';
if($id = $matches[1]){ 
           echo '<script>jQuery(function(){ app.events.trigger('audioplayer.pause') });    </script>'; } 
 ?>

1 个答案:

答案 0 :(得分:2)

转义'

 echo '<script>jQuery(function(){ app.events.trigger(\'audioplayer.pause\') });</script>';

此处也使用==代替=

if($id == $matches[1])