src/Framework/Form/Element/Input/Captcha.php
protected function generateEquation()
    {
        $ops = [' + ', ' - ', ' * ', ' / '];
        $equation = null;
        $rand1 = rand(1, 10);
        $rand2 = rand(1, 10);
        $op    = $ops[rand(0, 3)];
        // If the operator is division, keep the equation very simple, with no remainder
        if ($op == ' / ') {
            $mod = ($rand2 > $rand1) ? $rand2 % $rand1 : $rand1 % $rand2;
            while ($mod != 0) {
                $rand1 = rand(1, 10);
                $rand2 = rand(1, 10);
                $mod   = ($rand2 > $rand1) ? $rand2 % $rand1 : $rand1 % $rand2;
            }
        }
        $equation = ($rand2 > $rand1) ? $rand2 . $op . $rand1 : $rand1 . $op . $rand2;
        return $equation;
    }
protected function generateEquation()
    {
        $ops = [' + ', ' - ', ' * ', ' / '];
        $equation = null;
        $rand1 = rand(1, 10);
        $rand2 = rand(1, 10);
        $op    = $ops[rand(0, 3)];
        // If the operator is division, keep the equation very simple, with no remainder
        if ($op == ' / ') {
            $mod = ($rand2 > $rand1) ? $rand2 % $rand1 : $rand1 % $rand2;
            while ($mod != 0) {
                $rand1 = rand(1, 10);
                $rand2 = rand(1, 10);
                $mod   = ($rand2 > $rand1) ? $rand2 % $rand1 : $rand1 % $rand2;
            }
        }
        $equation = ($rand2 > $rand1) ? $rand2 . $op . $rand1 : $rand1 . $op . $rand2;
        return $equation;
    }
protected function generateEquation ( ) { $ ops = [ ' + ' , ' - ' , ' * ' , ' / ' ] ; $ equation = null ; $ rand1 = rand ( 1 , 10 ) ; $ rand2 = rand ( 1 , 10 ) ; $ op = $ ops [ rand ( 0 , 3 ) ] ; // If the operator is division, keep the equation very simple, with no remainder if ( $ op == ' / ' ) { $ mod = ( $ rand2 > $ rand1 ) ? $ rand2 % $ rand1 : $ rand1 % $ rand2 ; while ( $ mod != 0 ) { $ rand1 = rand ( 1 , 10 ) ; $ rand2 = rand ( 1 , 10 ) ; $ mod = ( $ rand2 > $ rand1 ) ? $ rand2 % $ rand1 : $ rand1 % $ rand2 ; } } $ equation = ( $ rand2 > $ rand1 ) ? $ rand2 . $ op . $ rand1 : $ rand1 . $ op . $ rand2 ; return $ equation ; }
Randomly generate a simple, basic equation

@return string
Randomly generate a simple basic equation