Birazdaha basit ama ilk kod kadar kullanışlı değil
<?
$sayi = rand(1,5);
echo "<img src='image/".$sayi.".jpg'>";
?>