Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php变量smarty配置文件_Php_Smarty_Smarty3_Smarty2 - Fatal编程技术网

使用php变量smarty配置文件

使用php变量smarty配置文件,php,smarty,smarty3,smarty2,Php,Smarty,Smarty3,Smarty2,在我的php文件发送电子邮件,我想使用smarty配置变量,但目前我必须削减他们 这是PHP文件的一部分: PHP $messagecontent.=” bla bla bla bla$username xxxx$myitemname 收到xxx后,转到xxxx 随时都可以。; 目前,我正在创建不同的smarty配置变量,如下所示: $messagecontent .= $smarty->getConfigVariable('welcomemail1'). $username $sma

在我的php文件发送电子邮件,我想使用smarty配置变量,但目前我必须削减他们

这是PHP文件的一部分:

PHP

$messagecontent.=”
bla bla bla bla$username xxxx$myitemname
收到xxx后,转到xxxx

随时都可以。
目前,我正在创建不同的smarty配置变量,如下所示:

$messagecontent  .= $smarty->getConfigVariable('welcomemail1'). $username $smarty->getConfigVariable('welcomemail2'). $myitemname." </b>
    <p>When you receive xxx go to xxxx</p>
feel free to <a href=".WEBSITEHOST."contact-us.php>contact us </a> at any time.<br />";
$messagecontent.=$smarty->getConfigVariable('welcomemail1')$用户名$smarty->getConfigVariable('welcomemail2')$myitemname。“
收到xxx后,转到xxxx

随时都可以。
我可以一次完成所有工作吗(在smarty配置文件中包含php变量)

所以:$messagecontent=$smarty->getConfigVariable('welcomemail')

那么{welcomemail}将如何包括这些内容? e、 g welcomemail=“??”

您可以使用sprintf

i、 e.在您的配置文件中,您将

welcomemail = "bla bla bla %1$s blablabla %2$s ...."
然后是php

$messagecontent = sprintf ($smarty->getConfigVariable('welcomemail'),$username,$itemname);

但是,我认为创建邮件最简单、最灵活的方法是为邮件正文编写一个模板,用smarty进行处理,并在变量中获得输出,而不是在屏幕上显示它

Mmmh可能是这样的吗<代码>$messagecontent.=$smarty->fetch('string:{welcomemail}…')
$messagecontent = sprintf ($smarty->getConfigVariable('welcomemail'),$username,$itemname);