Jump to content

[SOLVED] Is there a command to make echo happen at different times?


PGTibs

Recommended Posts

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?

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);

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.

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.