好的,我会切入正题,我有这段代码会产生一个随机字符串:
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;
}
然后在我的贝宝 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 没有任何作用