dongmeiba6151 2013-01-29 13:41
浏览 89
已采纳

当HTML在PHP变量中时,在HTML中使用PHP变量

I've got a .php script. In a variable I have a added html, but in that html I want to get text from another variable, how do I do this?

This is the variable with html:

$ai_boc   = '
<html>
<head>
  <title>Notes by Douno</title>
</head>

<body>
<div align="center">
<div style="width:600px; height:auto; border-radius:10px; background-color:#F7F1B8; background-repeat: auto; font-family:Georgia;  color:#513414;">

    <div style="height:100px; padding-top:20px; padding-left:20px; text-align:left;">
    <p style="margin-bottom:0px; font-weight:bold; font-size:xx-large;">$ai_su</p>
    <p style="margin-top:5px; font-size:x-small; font-weight:bold;">$ai_da</p>
    </div>
        <div style="height:1px; background-image: url(http://dl.dropbox.com/u/99775621/divider.jpg); display:block; position:relative;">
        </div>
    <div style="position:relative; overflow:hidden;">

        <div style="height:auto; width:375; padding-left:20px; text-align:left; position:relative; float:left;">
            <div style="width:375px;"> <p style="font-size:x-small; font-weight:bold;"><?php echo $ai_bo?></p>
            </div>
        </div>

        <div style="height:auto; width:160px; padding-left:20px; padding-right:20px; text-align:left; position:relative; float:left;">
        <p style="font-size:x-small; font-weight:bold; vertical-align:bottom;">If this email is considered spam, please contact us.</br></br>This email was send via Notes. An Android app developed by Douno.</p>
        <a href="https://play.google.com/store/apps/details?id=appinventor.ai_L_Bogaerts_95.Notes">
        <img alt="Get it on Google Play"
        src="https://developer.android.com/images/brand/en_generic_rgb_wo_45.png" />
        </a>

        </div>

    </div>
        <div style="height:1px; background-image: url(http://dl.dropbox.com/u/99775621/divider.jpg); display:block; position:relative;">
        </div>
    <div style="height:100px; width:600px; display:inline-block; position:relative;">

    </div>      






</div>
</div>
</body>
</html>
';

I coudn't find any working explanation, so I hope someone here can help me further. The html is not finished... Still some changes I'm gonna make.

  • 写回答

9条回答 默认 最新

  • dousao6313 2013-01-29 13:43
    关注

    Use either string concatenation, or variable expansion:

     $html = '<html>'.$somevar.'</html>';      // concatenation
     $html = "<html>$somevar</html>";           // expansion, only works with double quotes (")
    

    But much better is to use a decent template system to separate HTML and PHP altogether.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(8条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记