Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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
Php Echo EOT-如何在其中使用循环和条件运算符?_Php_Wordpress_Woocommerce - Fatal编程技术网

Php Echo EOT-如何在其中使用循环和条件运算符?

Php Echo EOT-如何在其中使用循环和条件运算符?,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我有一个关于如下代码的问题: echo <<<EOT <div class="quick-view-list nav"> How can i use loop or conditional operator here? <a class="active" href="$similarProduct0"> <img src

我有一个关于如下代码的问题:

echo <<<EOT 
          <div class="quick-view-list nav">

                  How can i use loop or conditional operator here?

                <a class="active" href="$similarProduct0">
                  <img src="$similarProductImg0" alt="Similar Product" width="100px" height="112px">
                </a>
                <a href="$similarProduct1">
                  <img src="$similarProductImg1" alt="Similar Product" width="100px" height="112px">
                </a>
                <a href="$similarProduct2">
                  <img src="$similarProductImg2" alt="Similar Product" width="100px" height="112px">
                </a>
              </div>
         EOT;

echo您是否尝试过
ob\u start
ob\u get\u clean
?您的代码可以这样编写:

<?php // assuming php open here...


ob_start(); ?>
<div class="quick-view-list nav">
<?php
    // do your conditional operator here....
?>
<a class="active" href="<?php echo $similarProduct0; ?>">
<img src="<?php echo $similarProductImg0; ?>" alt="Similar Product" width="100px" height="112px">
</a>
<a href="<?php echo $similarProduct1; ?>">
<img src="<?php echo $similarProductImg1; ?>" alt="Similar Product" width="100px" height="112px">
</a>
<a href="<?php echo $similarProduct2; ?>">
<img src="<?php echo $similarProductImg2; ?>" alt="Similar Product" width="100px" height="112px">
</a>
</div>
<?php 
echo ob_get_clean();


您是否尝试过
ob\u start
ob\u get\u clean
?您的代码可以这样编写:

<?php // assuming php open here...


ob_start(); ?>
<div class="quick-view-list nav">
<?php
    // do your conditional operator here....
?>
<a class="active" href="<?php echo $similarProduct0; ?>">
<img src="<?php echo $similarProductImg0; ?>" alt="Similar Product" width="100px" height="112px">
</a>
<a href="<?php echo $similarProduct1; ?>">
<img src="<?php echo $similarProductImg1; ?>" alt="Similar Product" width="100px" height="112px">
</a>
<a href="<?php echo $similarProduct2; ?>">
<img src="<?php echo $similarProductImg2; ?>" alt="Similar Product" width="100px" height="112px">
</a>
</div>
<?php 
echo ob_get_clean();


只是试过了,它不起作用。没有显示任何内容。无论如何,谢谢。它应该可以工作,这里有一个例子,在演示中,你需要点击“执行代码”按钮来查看输出的工作情况。因为我的错误,它没有起作用。。。。谢谢只是试过了,它不起作用。没有显示任何内容。无论如何,谢谢。它应该可以工作,这里有一个例子,在演示中,你需要点击“执行代码”按钮来查看输出的工作情况。因为我的错误,它没有起作用。。。。谢谢