Skip to content

BaylorRae/php-split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Syntax

<?php

if( ab_test('show_message') ) {
    
}

$cart_title = ab_test('basket_title', 'Shopping Cart', 'Basket', 'Cart'); // Basket

ab_test('name', 'option 1', 'option 2', function($text) {
    echo $text;
});

// alias to Split\Experiment
function ab_test($name, $alternative_names = null) {
    return Split\Experiment($title, array_shift(func_get_args()));
}

// split/experiment.php

namespace Split;

class Experiment {
    
    public $name,
           $winner;
           
    private $alternatives;
    
    function __construct($name, array $alternative_names = null) {
        $this->name = $name;
        
        // store each alternative into its own class
        foreach( $alternative_names as $alternative_name ) {
            array_push($this->alternatives, new Alternative($alternative_name, $name));
        }
    }
       
}

?>

About

The source to my A/B testing framework with PHP videos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages