我是初学者,我的电子邮件激活功能出现了小错误。错误在for循环的行中。
<?php
function generateCode(){
$codelength = 20;
// The length of the activation code.
$characters = "abcdefghijklmnopqrstuvwxyz1234567890"; // All accepted characters.
$activatecode = "";
for($i=0;$i<=$codelength;$i++){
$activatecode .= substr(str_shuffle($characters),0,1);
}
return $activatecode;
}
$userActivationCode = generateCode();
?>
您的一些源代码是HTML编码的。也许你是从网站上复制/粘贴的。
在具有for
循环的线路上,将<
更改为<
。
您的小于符号是html编码的。
for($i=0;$i<=$codelength;$i++){
更改为
for($i=0;$i<=$codelength;$i++){
$i<
不是有效的条件
你可能是说:
for($i=0;$i<=$codelength;$i++){
<?php
function generateCode(){
$codelength = 20;
// The length of the activation code.
$characters = "abcdefghijklmnopqrstuvwxyz1234567890"; // All accepted characters.
$activatecode = "";
for($i=0;<=$codelength;$i++){
$activatecode .= substr(str_shuffle($characters),0,1);
}
return $activatecode;
}
$userActivationCode = generateCode();
?>