- rand: documentation ( source)
<?php
//Intialize the input
$score=rand(50,100);
//Determine the Grade
function p($a,$b) { echo $a . " >= " . $b; return $a>=$b; }
$grade=(p($score,90))?'A':(
p($score,80)?'B':(
p($score,70)?'C':(
p($score,60)?'D':'F')));
//Output the Results
echo "<h1>A score of $score = $grade</h1>";