Tutto ok! funziona perfettamete! il codice è questo:

<?php
$code = rand(1, 10);
echo "$code";

if (rand(1,10)>7)
{
header('Location: http://www.google.com');
exit();
}?>

grazie ancora!