hackerman Posted June 11, 2007 Report Share Posted June 11, 2007 (edited) Man vajag, lai skripts pats automātiski strādātu. Laikam to dara ar sleep? Nu karoč, piem. mans skripts: <? $krutais_teksts = "testttttttttt"; $fails = "test.dat"; $atver = fopen($fails, "a"); $raksta = fwrite($atver, $krutais_teksts. "\r\n"); echo "yaaaa"; sleep(5); ?> A nah neiet? :D Pēc idejas vajadzēja ik pa 5 sec ierakstīt.... Edited June 11, 2007 by hackerman Link to comment Share on other sites More sharing options...
Delfins Posted June 11, 2007 Report Share Posted June 11, 2007 kā tad. Link to comment Share on other sites More sharing options...
hackerman Posted June 11, 2007 Author Report Share Posted June 11, 2007 nu labi, saki kur kļūda ;D Link to comment Share on other sites More sharing options...
Val Posted June 11, 2007 Report Share Posted June 11, 2007 pēc idejas nekas tur ik pa 5 sek nenotiks :) Link to comment Share on other sites More sharing options...
hackerman Posted June 11, 2007 Author Report Share Posted June 11, 2007 Nu moška kāds pateiks kā ir pareizi? Link to comment Share on other sites More sharing options...
andrisp Posted June 11, 2007 Report Share Posted June 11, 2007 Taisi ciklu, kas mūžīgi atkārtojas, un to sleep liec iekš viņa. Tikai neaizmirsti tad arī atslēgt laika limitu. (set_time_limit()) Link to comment Share on other sites More sharing options...
hackerman Posted June 11, 2007 Author Report Share Posted June 11, 2007 ēem... Varētu lūdzu kādu piemēru? ;D Link to comment Share on other sites More sharing options...
Val Posted June 11, 2007 Report Share Posted June 11, 2007 for(;;){ //te tavs mūžīgais kods }; Link to comment Share on other sites More sharing options...
andrisp Posted June 11, 2007 Report Share Posted June 11, 2007 Val, for tam nav domāts. php.net/while Link to comment Share on other sites More sharing options...
Val Posted June 11, 2007 Report Share Posted June 11, 2007 Ar ko šamais sliktāks? Darbojas lēnāk? Link to comment Share on other sites More sharing options...
andrisp Posted June 11, 2007 Report Share Posted June 11, 2007 Nu for ir vairāk paredzēts šādi pielietot: for($i = 0; $i < 100; $i ++) { ... } Protams, ar for var uztaisīt arī mūžīgu ciklu, bet ērtāk un loģiskāk nebūtu ar while ?: while(1) { ... } Link to comment Share on other sites More sharing options...
bubu Posted June 11, 2007 Report Share Posted June 11, 2007 No vecum-veciem laikiem, kad visi programmēja C'niekā, tad rakstīt for(;;) bija elītāk, nekā while(1). Link to comment Share on other sites More sharing options...
Grey_Wolf Posted June 12, 2007 Report Share Posted June 12, 2007 bubu --> un arii tagad :) while rakstaas tad KAD nezini kad ciklam jaabeidzaas (vai apgriestais cikls) .... tiiri no ASM viedoklja vinsh izveidots krietni resusrsu rijiigaaks...... Link to comment Share on other sites More sharing options...
andrisp Posted June 12, 2007 Report Share Posted June 12, 2007 Godīgi sakot pat nezināju, ka var tā ar for izrīkoties. Link to comment Share on other sites More sharing options...
bubu Posted June 12, 2007 Report Share Posted June 12, 2007 bubu --> un arii tagad :) Es jau nesaku, ka nevar. Tagad vienkārši cilvēki sākuši saprast, ka jāraksta vairāk rakstīt lasāmāks kods, nevis lītāks ;) tiiri no ASM viedoklja vinsh izveidots krietni resusrsu rijiigaaks...... Normāls kompilētājs (runa nav vairs par php) optimizēs pietiekoši labi to ciklu un nebūs nekādas atšķirības zemā līmenī. Godīgi sakot pat nezināju, ka var tā ar for izrīkoties./quote]Foram var jebkura no trīs daļām būt tukša, nav obligāti visām trim. Piemēram: for ($i=4; $i<111;) { ...; $i++; } Un ne tikai tukša, bet tajā var būt arī vairākas izteiksmes: for ($i=1,$j=2; $i<111; $i++, $j--, $a=asds($j)) { ... } Link to comment Share on other sites More sharing options...
Recommended Posts