PGTibs Posted February 9, 2009 Share Posted February 9, 2009 I have alot of lines of echo and i basically want a few seconds gap between each of them appearing. Is this possible? echo "<font face=verdana size=1><br><br>Enhanching your colour scheme..."; echo "<font face=verdana size=1><br>Generating colours with antigraphicalpixels..."; echo "<font face=verdana size=1><br>Creating mirrored colour pixels..."; echo "<font face=verdana size=1><br>Generating pretty colours..."; echo "<font face=verdana size=1><br>Generating oven gloves for oven protection..."; echo "<font face=verdana size=1><br>Generating oven to bake colours...?"; echo "<font face=verdana size=1><br>Cook on hot for 20 minutes and leave to cool..."; Whats the command or javascript etc to make the echo delay between each line to show at different times? Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/ Share on other sites More sharing options...
Maq Posted February 9, 2009 Share Posted February 9, 2009 Try sleep(). Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758364 Share on other sites More sharing options...
PGTibs Posted February 9, 2009 Author Share Posted February 9, 2009 It works but on page load it just makes the page load for the amount of time instead of loading an echo, waiting and then loading the next echo? echo "<font face=verdana size=1><br><br>Congratulations! Your colours have been accepted."; sleep(2); echo "<font face=verdana size=1><br><br>Enhanching your colour scheme..."; sleep(2); echo "<font face=verdana size=1><br>Generating colours with antigraphicalpixels..."; sleep(2); echo "<font face=verdana size=1><br>Creating mirrored colour pixels..."; sleep(2); echo "<font face=verdana size=1><br>Generating pretty colours..."; sleep(2); echo "<font face=verdana size=1><br>Generating oven gloves for oven protection..."; sleep(2); echo "<font face=verdana size=1><br>Generating oven to bake colours...?"; sleep(2); echo "<font face=verdana size=1><br>Cook on hot for 20 minutes and leave to cool..."; sleep(2); Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758392 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2009 Share Posted February 9, 2009 Web servers are designed to output whole pages. Php, the web server, and the browser all can do buffering, compression, and minimum length character block'ing that must be disabled or worked around to get incremental output from the server to be sent and to be rendered by the browser. If you want sequential or timed display of content in the browser, you would be better off sending it all at once from the server and using javascript to display it in the manor you want. Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758403 Share on other sites More sharing options...
PGTibs Posted February 9, 2009 Author Share Posted February 9, 2009 Oh right thanks, so if i just google for something like javascript time delay or something? Or will i need to code from scratch? Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758446 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2009 Share Posted February 9, 2009 If you just want to sequentially reveal a series of lines, you can probably find an existing script. In fact if you search for "javascript sequential reveal" you will get a lot of hits. I would recommend starting with - http://www.dynamicdrive.com/dynamicindex17/seqreveal.htm Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758452 Share on other sites More sharing options...
TheLoveableMonty Posted February 9, 2009 Share Posted February 9, 2009 I had a similar query. I went the long way about it, but essentially what I did is created a file containing two numerals with a separator - the current value and max value (the max value being used to reset the current value to "1"). Then assign each line to an array and echo the array instance with the current number. For example: $i = CURRENT NUMBER if ($i <= $maxValue) { echo "$array[$i]"; } else { $i = "0"; echo "$array[$i]"; } $i++; It's a summary as to how the code would work. Your best bet, however, is a DHTML ticker. There's many available online and they're all pretty efficient. As mentioned before, PHP is essentially a server application and is less dynamic in terms of varying display. PHP fit my purpose fine as I needed to progress through a list every fifteen seconds to span accross different browser sessions. That's the best advice I can give on that. Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758477 Share on other sites More sharing options...
PGTibs Posted February 9, 2009 Author Share Posted February 9, 2009 Big thanks, it worked very well the script on the link... http://www.dynamicdrive.com/dynamicindex17/seqreveal.htm And thanks for the info on a more php way, i'll give that a try some other time. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/144522-solved-is-there-a-command-to-make-echo-happen-at-different-times/#findComment-758488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.