【问题标题】:Store html content into php variable?将html内容存储到php变量中?
【发布时间】:2017-04-08 20:23:19
【问题描述】:

我的php页面中有一些html是我从数据库中获取的,将在我的网页中多次使用,所以我想把它放到一个php变量中以备后用。

我的示例代码是

<div class="info">
  Some content from database here...
  <div class="more">
     Some more text...
  </div>
</div>

如何将此 html 存储到 php 变量中?

还请告诉我如何回显该变量的内容?

【问题讨论】:

  • 跟PHP strings打个招呼。
  • Stack Overflow 不是代码编写服务。你应该做一些研究,试一试,然后当你碰壁时回来问一个minimal reproducible example的问题。编码快乐!

标签: php database


【解决方案1】:

我同意@Jon Stirling 但你可以这样做:

$htmlData = '<div class="info">
  Some content from database here...
  <div class="more">
     Some more text...
  </div>
</div>';

你可以打印这个

echo $htmlData;

【讨论】:

    猜你喜欢
    • 2015-09-20
    • 2016-10-15
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多