Execution time limit exceeded with PHP random number generator -


i'm trying make program prints random number every 3 seconds, mistake "maximum execution time of 30 seconds exceeded", sorry have no experience in php , know functions clear memory, appreciate .

ejemplo(); function ejemplo() {     $c=null;      $c=mt_rand(60,200);      sleep(3);      clear();     ejemplo();  }  

you can use explicit flushing load random number every 3 seconds:

<?php  ob_implicit_flush(true);  ejemplo(); function ejemplo() {     $c = mt_rand(60,200);      ob_end_flush();         echo $c . "<br>\n";     ob_start();      sleep(3);     ejemplo();  } 

however, can't clear output once it's outputted (without using javascript).

another method use javascript:

var refresh = function() {    document.getelementbyid("number").innerhtml = math.round(math.random() * 140) + 60;  };    refresh();    setinterval(refresh, 3000);
<div id="number"></div>


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -