I am trying to write a simple script to act as a sort-of captcha in a form. I know this isn't nowhere near as good as using a captcha but I wanted to do it as I'm new to PHP and it's good learning.
<?php
$a = rand(1, 10);
$b = rand(1, 10);
$array = array(
"+",
"-",
"/",
"*"
);
$operator = $array[array_rand($array)];
$answer = ;
?>
What should I use to calculate $answer
?
I need PHP to do $answer = $a $operator $b
, for example $answer = 8 + 2
so $answer = 10
.