下面代码中去除q和y避免什么可读性问题


   
  To quickly build a human-readable random string for a captcha per example :
  

<?php

function random($length = 8)
{
$chars = 'bcdfghjklmnprstvwxzaeiou';

for ($p = 0; $p < $length; $p++)
{
$result .= ($p%2) ? $chars[mt_rand(19, 23)] : $chars[mt_rand(0, 18)];
}

return $result;
}

?>

Note that I have removed q and y from $chars to avoid readability problems.

php

神枪·深红 9 years, 1 month ago

这是用来生成图片验证码吧(...for a captcha),这里的“可读性问题”是说最后图片上的字符的可读性,不是代码的可读性。

g和q,y和u,v经过各种处理之后,很容易让用户混淆。

Ppeng answered 9 years, 1 month ago

Your Answer