PHP code example of utopia-php / ab

1. Go to this page and download the library: Download utopia-php/ab 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/ */

    

utopia-php / ab example snippets




topia\AB\Test;

$test = new Test('example');

$test
    ->variation('title1', 'Hello World', 40) // 40% probability
    ->variation('title2', 'Foo Bar', 30) // 30% probability
    ->variation('title3', function () { // 30% probability
        return 'Title from a callback function';
    }, 30)
;
    
$debug  = [];
    
for($i=0; $i<10000; $i++) {
    $debug[$test->run()]++;
}
    
var_dump($debug);
    
bash
composer