回显HTML和PHP的混合,给出一个错误


Echo mix of HTML and PHP giving an error

我试图回应这个长语句,尝试在这里查看其他答案,但没有什么能解决它。

Error: 
Parse error: parse error, expecting `','' or `';'' 
Errors parsing -

<?php 
$videoEmbed = get_post_meta( get_the_id(), 'ctslider_videoembedcode', true ); 
$postThumb = the_post_thumbnail();

echo '<div onclick="thevid=document.getElementById('thevideo'); thevid.style.display='block'; this.style.display='none'"><img src="'.echo $postThumb.'" style="cursor:pointer" /></div><div id="thevideo" style="display:none">"'.echo $videoEmbed.'"</div>';?>

您必须逃离所以它给出了:

echo '<div onclick="thevid=document.getElementById(''thevideo''); thevid.style.display=''block''; this.style.display=''none''"><img src="'.$postThumb.'" style="cursor:pointer" /></div><div id="thevideo" style="display:none">"'.$videoEmbed.'"</div>';

并且您不需要第一个回波内部的回波

您真的需要回显div吗?你不能这样做吗:

<div onclick="thevid=document.getElementById('thevideo'); thevid.style.display='block'; this.style.display='none'"> 
    <img src="<?php echo $postThumb ?>" style="cursor:pointer" />
</div>
<div id="thevideo" style="display:none">
    <?php echo $videoEmbed ?>
</div>

你能试试这个吗,

echo '<div onclick="thevid=document.getElementById(''thevideo''); thevid.style.display=''block''; this.style.display=''none''">
         <img src="'.$postThumb.'" style="cursor:pointer" />
      </div>
      <div id="thevideo" style="display:none">"'.$videoEmbed.'"</div>';

您必须在键入的任何php命令周围添加<?php ?>。尝试<?php echo "whatever you want here"?>

相关文章: