0

我有一个变量,我想要混合变量和一个字符串。例如:

$body   = 'Dear customer'.$fname.$textmsg.$footer.$website ;

但这种格式不起作用。输出是:

Dear customer Mary0

请帮助这个字符串。

4

2 回答 2

1

是因为其他变量为空。您有两种连接字符串的方法。

第一的:

$body = 'Dear customer'.$fname.$textmsg.$footer.$website;

第二:

$body   = "Dear customer $fname$textmsg$footer$website";
于 2013-10-01T16:40:21.207 回答
0

要么你没有预先定义你的其他变量,要么有其他东西破坏了你的代码,它没有完整地发布。

这是我作为示例放在一起的一些东西(经过测试)

PHP

<?php
$fname = "Mary";
$textmsg = "Thank you for dropping by my Web site.";
$footer = "This is a footer that will show at 10px from the bottom with the help of CSS.";
$website = "http://www.example.com";
$body = 'Dear (customer) '.$fname . "<br>" .$textmsg . "<div align='center' id='footer'>" . $footer . "</div>" . "<div id='website'>$fname, " . "<a href='" .$website . "'>click here to visit my Web site.</a>" . "</div>";
echo $body;
?>

CSS

<style>
body {
margin:10px 0px; padding:0px;
text-align:center;
}

#footer {
position:absolute;
bottom: 10px;
margin: 0 auto;
width: 100%;
text-align:center;
}
</style>

这将产生(带有一些个性化):

(居中)
亲爱的(客户)玛丽
感谢您访问我的网站。
玛丽,点击这里访问我的网站

(距底部 10 像素)
这是一个在 CSS 的帮助下将在距底部 10 像素处显示的页脚。

于 2013-10-01T17:23:05.670 回答