php代码的语法错误

php代码的语法错误,php,Php,请帮我输入这个代码 <?php if (!empty($this->product->customfieldsSorted['youtube'])) { $this->position = 'youtube'; echo '<button class="shop_tablinks tab2" onclick='"openSpecs(event, 'Specs3')"' >'; echo JText::_('Video');

请帮我输入这个代码

<?php
if (!empty($this->product->customfieldsSorted['youtube'])) {
    $this->position = 'youtube';
    echo '<button class="shop_tablinks tab2"  onclick='"openSpecs(event, 'Specs3')"' >';
    echo JText::_('Video'); 
    echo '</button>';
} // Product Custom ontop end
?>

将您的代码替换为以下代码:

<?php  if (!empty($this->product->customfieldsSorted['youtube'])) {
        $this->position = 'youtube';
        echo '<button class="shop_tablinks tab2"  onclick="openSpecs(event, \'Specs3\')">';
        echo JText::_('Video'); 
       echo '</button>';
   } // Product Custom ontop end
    ?>

如果要在使用
'
进行回声时在html代码中使用,则需要对
'
使用转义运算符。因此,在HTml代码中,它将其作为concat运算符。

更改行

echo '<button class="shop_tablinks tab2"  onclick='"openSpecs(event, 'Specs3')"' >';
echo';

echo';
最终代码:

if (!empty($this->product->customfieldsSorted['youtube'])) {
    $this->position = 'youtube';
    echo '<button class="shop_tablinks tab2"  onclick="openSpecs(event, \'Specs3\')" >';
    echo JText::_('Video'); 
    echo '</button>';
}
if(!empty($this->product->customfieldsSorted['youtube'])){
$this->position='youtube';
回声';
echo JText::((“视频”);
回声';
}

你有什么问题?“你没有解释任何事情。如果你指出你改变了什么以及为什么改变,那么它的可能副本可能会改进你的答案。”瓦里罗西
echo '<button class="shop_tablinks tab2"  onclick="openSpecs(event, \'Specs3\')" >';
if (!empty($this->product->customfieldsSorted['youtube'])) {
    $this->position = 'youtube';
    echo '<button class="shop_tablinks tab2"  onclick="openSpecs(event, \'Specs3\')" >';
    echo JText::_('Video'); 
    echo '</button>';
}