2013-02-28 21 views
0

我是初學者,我的電子郵件激活功能有小錯誤。該錯誤位於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(); 
?> 

回答

0

你的符號少於html編碼。

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

變化

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

謝謝您得到它了。 – 2013-02-28 20:40:19

3

您的某些源代碼是HTML編碼的。也許你已經從網站上覆制/粘貼它。

在與for循環的行上,將&lt;更改爲<

0
$i&lt 

是不是一個有效的條件

你大概的意思:

for($i=0;$i<=$codelength;$i++){ 
0
<?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(); 
?>