回声EOT - 我如何在其中使用循环和条件运算符?

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


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;

这有可能吗?刚刚发现EOT,它非常适合我 - html比这里长得多。


有好的一天!


森林海
浏览 137回答 1
1回答

喵喵时光机

你试过吗?您的代码可以这样编写:ob_startob_get_clean<?php // assuming php open here...ob_start(); ?><div class="quick-view-list nav"><?php&nbsp; &nbsp; // 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&nbsp;echo ob_get_clean();
打开App,查看更多内容
随时随地看视频慕课网APP