PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Alex I.   PseudoGen   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage
Class: PseudoGen
Generate a pseudo random string
Author: By
Last change:
Date: 15 years ago
Size: 782 bytes
 

Contents

Class file image Download
<?php
/**
 * This is an example of how to use the pseudogen class
 *
 * @author Alex Iordache iordachej@gmail.com
 * @copyright 2009 Alex Iordache. Released under GPL terms
 * @version 1.0
 */

require('pseudogen.class.php');
$p = new pseudogen();

//use a set of 62 characters
$p->set_charset('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');

//make it 6 letter long
$matrix = $p->generate_set(6);
echo(
"The MATRIX is:\r\n");
print_r($matrix);
echo(
"\r\n\r\n");

//setting the character set is only for demonstration. In most cases one will want to generate it once then
//save it directly into the class file
$p->set_charset_matrix($matrix);

for (
$i = 0; $i < 100; $i++) {
   
$rnd = rand(100000, 999999);
    echo
$rnd . ' => ' . $p->encode( $rnd ) . "\r\n";
}
?>