Rastgele Sayı Oluşturma
8
●4.254
- 04-11-2008, 14:17:32Üyeliği durdurulduHarfleri bilmiyorum ama sayıyı rand(); ile yapabilirsin...
<?php echo rand(5, 150); // 5 ve 150 arasında rastgele sayı üretir ?>
- 04-11-2008, 14:18:03
<?php $rastgel = rand(50,100); echo $rastgel; ?>
buda güvenlik kodu mesela
<?php session_start(); $guvenlik_kodu= $_SESSION['guvenlik_kodu']; $resim=imagecreate(100,40); $resim_siyah = imagecolorallocate($resim,210,210,210); $resim_beyaz = imagecolorallocate($resim,0,0,0); imagefill($resim,0,0,$resim_siyah); imagechar($resim,4,20,13,$guvenlik_kodu[0],$resim_beyaz); imagechar($resim,5,40,13,$guvenlik_kodu[1],$resim_beyaz); imagechar($resim,3,60,13,$guvenlik_kodu[2],$resim_beyaz); imagechar($resim,4,80,13,$guvenlik_kodu[3],$resim_beyaz); header('Content-type: image/png'); imagepng($resim); ?> - 04-11-2008, 14:30:13
- 04-11-2008, 14:34:12Güzel bir fonksiyon oldu

<? function myRandom($min, $max, $isLetter = false, $minLetter = 'a', $maxLetter = 'z'){ $rand = rand($min, $max); if ($isLetter) { $rangeLetter = range($minLetter, $maxLetter); $countLetter = count($rangeLetter); } for($i = 0; $i < $rand; $i++){ if(rand(0, 1) == 1){ $temp.=rand(0, 9); }elseif($isLetter){ $temp.=$rangeLetter{rand(0, $countLetter - 1)}; } } return $temp; } echo myRandom(10, 50, true, 'a', 'f'); echo "<br>"; echo myRandom(20, 50); echo "<br>"; echo myRandom(10, 50, true); ?>Diğer verilen kodlarda çalışıyor...
