iceman adlı üyeden alıntı: mesajı görüntüle
merhaba, elimde boyle bir kod var. ama bu kod ile sayfa yenilendikçe sozler.txt ten çekilen söz degişiyor ben bunu 24 saatte bir söz olarak nasıl ayarlayabilirim? yardımcı olacaklara şimdiden teşekkürler.

<?
// Dosyayı okumak için aç
$dosya = fopen("sozler.txt","r");
// Dosyayı satır satır $sozler'e aktar
while($satir = fgets($dosya,1024))
$sozler[] = $satir;
// Dosyayı kapat
fclose($dosya);
// Diziden rastgele bir sözü $soz'e aktar
$soz = $sozler[rand(0,count($sozler)-1)];
// Sözü yazdır
echo "<i>".$soz."</i>";
?>
bu işine yarar gün dönümünü denemedim
<?php

class sozler {
    public function __construct($action='read'){
        if(!file_exists('sozler.lock')){
            $this->write();
        }

        switch($action){
            case 'read':
                $this->read();
                break;
            case 'write':
                $this->write();
                break;
            case 'select':
                $this->select();
                break;
            default:
                $this->read();
        }
    }
    public function read(){
        $handle     = fopen('sozler.lock', "r");
        $data       = unserialize(fread($handle, filesize('sozler.lock')));
        fclose($handle);

        if($data['tarih']=!date('Y-m-d')){
            $this->write();
            $this->read();
        } else {
            echo $data['soz'];
        }
        return false;

    }
    public function write(){
        $write = array();
        $write['tarih'] = date('Y-m-d');
        $write['soz'] = $this->select();
        if(file_put_contents('sozler.lock',serialize($write))){
            return true;
        }
        return false;
    }
    public function select(){
        $dosya = fopen("sozler.txt","r");
        while($satir = fgets($dosya,1024))
            $sozler[] = $satir;
        fclose($dosya);
        return $sozler[rand(0,count($sozler)-1)];
    }
}

new sozler();

?>