Quote or escape the limit string at the beginning of the here document (heredoc) to disable parameter substitution (variables).
In the following example, escape EOF as \EOF. You can also put the limit string in quotes: "EOF".
php <<\EOF <?php echo rand() . "\n"; EOF
php <<"EOF" <?php echo rand() . "\n"; EOF