好的,我会切入追逐,我有这个代码产生一个随机字符串:
function random_string()
{
$character_set_array = array();
//$character_set_array[] = array('count' => 2, 'characters' => 'AA');
$character_set_array[] = array('count' => 8, 'characters' => '0123456789');
$temp_array = array();
foreach ($character_set_array as $character_set) {
for ($i = 0; $i < $character_set['count']; $i++) {
$temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
}
}
shuffle($temp_array);
$pinstart = 'AA';
$pinend = implode('', $temp_array);
$pin = $pinstart.$pinend;
echo $pin;
}
然后在我的PayPal IPN中我有这个:
if($p->ipn_data["mc_gross"] > 0 && strcmp ($p->ipn_data["business"],$EMAIL) == 0 && ($p->ipn_data["item_number"]) == 1) {
$user = $p->ipn_data["custom"];
$date = $p->ipn_data["payment_date"];
$prodid = $p->ipn_data["item_number"];
$amount = $p->ipn_data["mc_gross"];
$amountTickets = 1;
$email = 'email@hotmail.com';
$subject = '[CODE] - Thank you for your donation';
$message = 'Your CODE IS, <? echo random_string(); ?>';
mail("$payer_email", "$subject",
$message.random_string(), "From: $email" );
$user = str_replace("_", " ", $user);
$user = str_replace("-", " ", $user);
$user = mysql_real_escape_string($user);
}
它会发送电子邮件但是它的代码是,它不会发布随机字符串。
我已尝试输入$ pin,$ pin = random_string();打印$ pin无效
答案 0 :(得分:0)
在echo $pin;
函数中将return $pin
更改为random_string
,因为您希望它返回一个字符串,而不是在现场打印出字符串,然后
$message = 'Your CODE IS, ' . random_string();
答案 1 :(得分:0)
random_string应该使用return not echo
然后
...
$subject = '[CODE] - Thank you for your donation';
$message = 'Your CODE IS,'. random_string();
mail("$payer_email", "$subject",
...