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 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)