uid generator - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of uid generator.php

  1. <?php
  2. $user = "user".uniqid();
  3.  
  4. function generarCodigo($longitud) {
  5.  $key = '';
  6.  $pattern = '1234567890abcdefghijklmnopqrstuvwxyz';
  7.  $max = strlen($pattern)-1;
  8.  for($i=0;$i < $longitud;$i++) $key .= $pattern{mt_rand(0,$max)};
  9.  return $key;
  10. }
  11.  
  12. //Ejemplo de uso
  13.  
  14. echo $user.generarCodigo(6); // genera un código de 6 caracteres de longitud.
  15. ?>
File Description
  • uid generator
  • PHP Code
  • 14 Jan-2020
  • 358 Bytes
You can Share it: