why sleep() not returning anything

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LeetheFIRST
Forum Newbie
Posts: 2
Joined: Thu Aug 06, 2009 11:22 pm

why sleep() not returning anything

Post by LeetheFIRST »

Here is my code, an output of 0 is expected after sleep() suceeded, but instead nothing is printed. can anyone tell me why, please?

Code: Select all

 
<?php
      print "Hello   Web!!!";
 
      print "\n";
 
      print sleep(8);
?>
 
marty pain
Forum Contributor
Posts: 105
Joined: Thu Jun 11, 2009 5:32 am
Location: Essex

Re: why sleep() not returning anything

Post by marty pain »

In this case sleep should return with 0.

What do you get?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: why sleep() not returning anything

Post by Mark Baker »

Try

Code: Select all

print(sleep(8));
print doesn't normally need the brackets, but it may make a difference
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: why sleep() not returning anything

Post by pickle »

try:

Code: Select all

var_dump(sleep(8));
That'll tell you exactly what's being returned
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
LeetheFIRST
Forum Newbie
Posts: 2
Joined: Thu Aug 06, 2009 11:22 pm

Re: why sleep() not returning anything

Post by LeetheFIRST »

pickle wrote:try:

Code: Select all

var_dump(sleep(8));
That'll tell you exactly what's being returned
I got NULL from this. don't know why 'cause the program did sleep for 8 sec!
User avatar
&nbsp;
Forum Newbie
Posts: 2
Joined: Sun Aug 09, 2009 9:00 pm
Location: Colorado, USA

Re: why sleep() not returning anything

Post by &nbsp; »

I'm not sure why you would ever want to use sleep() in an application. :P
Post Reply