我的电子邮件激活功能中的错误在哪里


Where is the error in my email activation function?

我是初学者,我的电子邮件激活功能出现了小错误。错误在for循环的行中。

<?php
function generateCode(){
$codelength = 20; 
// The length of the activation code.
$characters = "abcdefghijklmnopqrstuvwxyz1234567890"; // All accepted characters.
$activatecode = "";
for($i=0;$i&lt;=$codelength;$i++){
$activatecode .= substr(str_shuffle($characters),0,1);
}
return $activatecode;
}
$userActivationCode = generateCode();
?>

您的一些源代码是HTML编码的。也许你是从网站上复制/粘贴的。

在具有for循环的线路上,将&lt;更改为<

您的小于符号是html编码的。

for($i=0;$i&lt;=$codelength;$i++){

更改为

for($i=0;$i<=$codelength;$i++){
$i&lt

不是有效的条件

你可能是说:

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();
?>