spaceace Posted July 18, 2007 Share Posted July 18, 2007 Hi, Consider the following script; <? echo 'Hello '; sleep(1); echo 'world!'; ?> Is it possible to have php process the script so that the web page instantly displays Hello, then pauses for 1 second and then displays world!, instead of what is actually happening which is a 1 second pause followed by Hello world! TIA Jason Quote Link to comment Share on other sites More sharing options...
paul2463 Posted July 18, 2007 Share Posted July 18, 2007 have a look <a href="http://uk3.php.net/flush"> here at the manual for FLUSH()</a> Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted July 18, 2007 Share Posted July 18, 2007 put them in two different tags? <?php // <?php is more versatile than just <? by the way... echo 'Hello'; sleep(1); ?> <?php echo 'World'; ?> but just so you know... neither works for me at all... I'd be more tempted to use Java script for something like this due to the way it handles updating display settings. It's not really something that a server does particularly well. it's much better for the local machine to do it because of different download speeds. Especially if the delay's only 1 second long. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 18, 2007 Share Posted July 18, 2007 is that not a document effect? If so it's something that should be controlled by javascript. <?php echo 'Hello '; echo '<span id="delay"></span><noscript>world!</noscript>'; ?> javascript function triggerCont() { setTimeOut(delayText,1000); } function delayText() { el = document.getElementById('delay'); el.innerHTML = 'world!'; } then put the onload="triggerCont();" attribute in you body tag. Quote Link to comment Share on other sites More sharing options...
spaceace Posted July 18, 2007 Author Share Posted July 18, 2007 Brilliant, thanks for your help! Here's what solved it for me; <? echo "hello"; flush(); sleep(1); echo "world"; ?> Quote Link to comment 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.