php – 如何在echo调用中运行函数

前端之家收集整理的这篇文章主要介绍了php – 如何在echo调用中运行函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是一个快速而简单的问题.我有一个糟糕的一天,不知道如何做到这一点:

我需要做的是……

我正在检查网址中的PMD,如果这样回应:

<?PHP 
        if ( isset($_GET['pmd']) ) { 
          echo"<div class=\"response\"><p style=\"width:350px; height:200px; vertical-align:middle;\"><strong>Thank you for acting as a &quot;watchman on the walls&quot; of Jerusalem! Your name will now appear on our virtual wall.<br><br>You can also catch up on the latest news from Israel by visiting our news Feed below.</strong></p></div>";
        }else { etc...

我需要包含的内容是像触发跟踪像素的图像.

<img src="url.com?cid=12345&aid=1234&oid=<?PHP echo mt_rand(); ?>&quantity=1" height="1" width="1" />

我想拥有的是:

<?PHP 
        if ( isset($_GET['pmd']) ) { 
          echo"<div class=\"response\"><p style=\"width:350px; height:200px; vertical-align:middle;\"><strong>Thank you for acting as a &quot;watchman on the walls&quot; of Jerusalem! Your name will now appear on our virtual wall.<br><br>You can also catch up on the latest news from Israel by visiting our news Feed below.</strong></p>
          <br />
          <img src="url.com?cid=12345&aid=1234&oid=<?PHP echo mt_rand(); ?>&quantity=1" height="1" width="1" />
          </div>";
        }else {

要使mt_rand()函数触发,我需要做什么?

谢谢,

马特

@H_403_22@
您可以使用此语法:
<?PHP if ( isset($_GET['pmd']) ): ?>
    <div class="response"><p style="width:350px; height:200px; vertical-align:middle;"><strong>Thank you for acting as a &quot;watchman on the walls&quot; of Jerusalem! Your name will now appear on our virtual wall.<br><br>You can also catch up on the latest news from Israel by visiting our news Feed below.</strong></p>
      <br />
      <img src="url.com?cid=12345&aid=1234&oid=<?PHP echo mt_rand(); ?>&quantity=1" height="1" width="1" />
    </div>
<?PHP else: ?>
    etc
<?PHP endif; ?>
原文链接:https://www.f2er.com/php/133760.html

猜你在找的PHP相关文章