dongyijing2353 2017-09-26 06:17
浏览 26
已采纳

没有使用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.

  • 写回答

1条回答 默认 最新

  • dqy13020940 2017-09-26 06:48
    关注

    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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题