Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

1 of 6
Captain Lightning
  • 10.8k
  • 4
  • 22
  • 17

PhP random string generator

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?

Captain Lightning
  • 10.8k
  • 4
  • 22
  • 17
lang-php

AltStyle によって変換されたページ (->オリジナル) /