PHP code example of wikimedia / alea

1. Go to this page and download the library: Download wikimedia/alea library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wikimedia / alea example snippets


use Wikimedia\Alea\Alea;

$prng = new Alea(); // add an optional seed parameter
$nextRandom = $prng->random(); // or ->uint32() or ->fract53()

$prng1 = new Alea(200);

$prng1->random();
$prng1->random();

$prng2 = Alea::createWithState( $prng1->exportState() );

assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );