没有使用PHP获得电子邮件模板的价值
I have an issue while sending email to user using PHP. I am binding some value inside the email template but not getting those value inside the template while that sent to user's inbox. I am explaining my code below.
$msgSub="Login credentials and verification link for Spesh";
$u_name='Username-"'.$email.'"';
$u_pass='Password-"'.$password.'"';
$url='http://oditek.in/spesh/mobileapi/categoryproduct.php?item=4&acn=2&email='+$email;
ob_start();
include "verification.php";
$msg_body=ob_get_clean();
$is_send=sendMail($email,'info@thespesh.com',$msgSub,$msg_body);
verification.php:
<br /><br />
<b><?php echo $u_name ?></b><br /><br />
<b><?php echo $u_pass ?></b>
<b><?php echo $url ?></b>
<br /><br />
function sendMail($to,$from,$subject,$msg_body){
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
$headers .= 'From: '.$from . "
";
$id=mail($to,$subject,$msg_body,$headers);
if($id){
return 1;
}else{
return 0;
}
}
Here I am getting value for $u_name and $u_pass
but for $url
the value is coming 0
. In the first file I have already declared the value for url
. The value of url should come.Please help me.
使用PHP向用户发送电子邮件时遇到问题。 我在电子邮件模板中绑定了一些值,但在发送到用户收件箱时没有在模板中获取这些值。 我正在解释下面的代码。 p>
$ msgSub =“Spesh的登录凭据和验证链接”;
$ u_name ='用户名 - “'。$ email。'” ';
$的u_pass =' 密码 - “ '$的密码。'” ';
$的URL =' HTTP://oditek.in/spesh/mobileapi/categoryproduct.php项目= 4和; ACN = 2及 email ='+ $ email;
ob_start();
include“verification.php”;
$ msg_body = ob_get_clean();
$ is_send = sendMail($ email,'info @ thespesh.com',$ msgSub, $ msg_body);
code> pre>
verification.php: p>
blockquote>
&lt; br /&gt;&lt; br /&gt;
&lt; b&gt;&lt;?php echo $ u_name?&gt;&lt; / b&gt;&lt; br /&gt;&lt; br /&gt;
&lt; b&gt;&lt; ;?php echo $ u_pass?&gt;&lt; / b&gt;
&lt; b&gt;&lt;?php echo $ url?&gt;&lt; / b&gt;
&lt; br /&gt;&lt; br /&gt;
\ n
函数sendMail($ to,$ from,$ subject,$ msg_body){
$ headers =“MIME-Version:1.0”。 “
”;
$ headers。=“Content-type:text / html; charset = iso-8859-1”。 “
”;
$ headers。='From:'。$ from from。 “
”;
$ id = mail($ to,$ subject,$ msg_body,$ headers);
if($ id){
return 1;
} else {
return 0;
}
}
code> pre>
这里我为 $ u_name和$ u_pass code>获得了价值,但对于 $ url code> 值即将到来 0 code>。 在第一个文件中,我已经声明了 url code>的值。 url的值应该来了。请帮助我。 p>
div>
The problem is obviously on the way $url
is set:
$url = 'http://.../categoryproduct.php?item=4&acn=2&email=' + $email;
(I removed some unimportant part of the first string to let the issue come into focus).
The addition operator (+
) computes the sum of its operands. If the operands are strings they are first converted to numbers. When a string is converted to a number, only the maximum-length prefix of the string that looks like a number is used, the rest is ignored. In this code the two strings start with letters, not digits, that's why they both are converted to 0
(zero).
To concatenate strings, use the concatenation operator (.
):
$url = 'http://oditek.in/spesh/mobileapi/categoryproduct.php?item=4&acn=2&email='
. $email;