Jump to content


Photo

pause the script


  • Please log in to reply
3 replies to this topic

#1 thor erik

thor erik
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 August 2006 - 03:36 PM

Well i'm going to try out an idea i had.

but i got this problem that the script is done loading before the test image is done.

how can i make the script continue running until the image is loaded?

the scrip:
<?php
$file = "waiting.jpg";
$size = filesize($file);
$timer = microtime();
$size = filesize($file);
$bits = $size*"9";
$kbits = $bits/'1000';
$kbps = $kbits/$timer;
echo '<img src="waiting.jpg" />'; // test image. 3.22 mb large
echo "<br />";
echo $kbps;
?>


#2 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 03 August 2006 - 03:42 PM

well you might want to check out the usleep() function @ http://www.php.net/usleep

but I think it might not help.
I'm not sure what your trying to do, but your logic might be flawed.
If you want it to display an image while the script executes - it won't work - because PHP runs server side and the script finishes running BEFORE it exports to the browser.
which means if you echo an image and then have PHP do stuff -- the image wont display until the entire script finishes running.

your alternative would be to either use AJAX - load the image then, call the script to load on another page in the background and replace the image w/ its results - this can be done with javascipt (google AJAX)

or, use two pages. the first one has the image load then a meta tag or something forwards to the page w/ the script.  the first page will hang, displaying the image, for as long as it takes the second page to finish processing.  then it will load the second page
"Confidence in the face of risk."

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 August 2006 - 03:46 PM

Remember, PHP runs on the SERVER and it's output is processed by the browser.

Ken

#4 thor erik

thor erik
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 August 2006 - 04:54 PM

well you might want to check out the usleep() function @ http://www.php.net/usleep

but I think it might not help.
I'm not sure what your trying to do, but your logic might be flawed.
If you want it to display an image while the script executes - it won't work - because PHP runs server side and the script finishes running BEFORE it exports to the browser.
which means if you echo an image and then have PHP do stuff -- the image wont display until the entire script finishes running.

your alternative would be to either use AJAX - load the image then, call the script to load on another page in the background and replace the image w/ its results - this can be done with javascipt (google AJAX)

or, use two pages. the first one has the image load then a meta tag or something forwards to the page w/ the script.  the first page will hang, displaying the image, for as long as it takes the second page to finish processing.  then it will load the second page


kk
can you give me an code example of the last version?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users