csdnceshi76
斗士狗
2010-12-04 22:56

Php 随机字符串生成器

  • random
  • string
  • php

I'm trying to create a randomized string in PHP, and I get absolutely no output with this:

<?php
function RandomString()
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randstring = '';
    for ($i = 0; $i < 10; $i++) {
        $randstring = $characters[rand(0, strlen($characters))];
    }
    return $randstring;
}
RandomString();
echo $randstring;

What am I doing wrong?

转载于:https://stackoverflow.com/questions/4356289/php-random-string-generator

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

30条回答

为你推荐

换一换