如何用<<
我想知道如何重写此代码以与 qq 一起使用:
$containerRight = <<<qq
<div class="container_right">
{echoLikeBox()}
<div class="join_us"><a href="#"><img src="images/join_us.png" width="304" height="44" alt=""></a></div>
<div class="box2"><a href="#"><img src="images/twitter_big.gif" width="304" height="292" alt=""></a></div>
<div class="box3"><a href="#"><img src="images/facebook.jpg" width="304" height="257" alt=""></a></div>
<div class="box4"><a href="#"><img src="images/google_ads.gif" width="304" height="164" alt=""></a></div>
<!-- container_right end --></div>;
qq;
echo $containerRight;
问题是我不知道如何在 <<< 内 echo 函数。 echoLikBox() 的代码是这样的:
function echoLikeBox()
{
$likeBox = <<<qq
<div class="box1">
<div class="box1_lft"><a href="#"><img src="images/tweet.jpg" width="108" height="20" alt=""></a></div>
<div class="box1_rht"><a href="#"><img src="images/like.jpg" width="82" height="20" alt=""></a></div>
<div class="clear"></div>
</div><!-- box1 end -->
qq;
echo $likeBox;
}
谢谢您的帮助。
编辑:在这里找到解决方案: 在 HEREDOC 字符串中调用 PHP 函数
抱歉,双重发帖。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web
技术交流群。
我想知道如何重写此代码以与 qq 一起使用:
$containerRight = <<<qq
<div class="container_right">
{echoLikeBox()}
<div class="join_us"><a href="#"><img src="images/join_us.png" width="304" height="44" alt=""></a></div>
<div class="box2"><a href="#"><img src="images/twitter_big.gif" width="304" height="292" alt=""></a></div>
<div class="box3"><a href="#"><img src="images/facebook.jpg" width="304" height="257" alt=""></a></div>
<div class="box4"><a href="#"><img src="images/google_ads.gif" width="304" height="164" alt=""></a></div>
<!-- container_right end --></div>;
qq;
echo $containerRight;
问题是我不知道如何在 <<< 内 echo 函数。 echoLikBox() 的代码是这样的:
function echoLikeBox()
{
$likeBox = <<<qq
<div class="box1">
<div class="box1_lft"><a href="#"><img src="images/tweet.jpg" width="108" height="20" alt=""></a></div>
<div class="box1_rht"><a href="#"><img src="images/like.jpg" width="82" height="20" alt=""></a></div>
<div class="clear"></div>
</div><!-- box1 end -->
qq;
echo $likeBox;
}
谢谢您的帮助。
编辑:在这里找到解决方案: 在 HEREDOC 字符串中调用 PHP 函数
抱歉,双重发帖。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想要更改“echoLikeBox()”函数,而不是回显其内容,而是将它们存储为字符串。您无法调用定界符字符串内的函数,但可以输出变量。因此,例如,您可以有:
然后就
在主体内部。
You may want to change the "echoLikeBox()" function to, instead of echoing its contents, store them as a string. You can't make a call to a function inside of heredoc strings, but you can output variables. So, for example, you could have:
and then just
inside of the main body.