Jump to content

a time out?


Michdd

Recommended Posts

That won't work, because I need it to do something else, not return an error. I was thinking about something like this:

 

<?php
$start = time();

function online($connection)
{
while(!$connection)
{
	if(time() - $start >= 2)
	{
		return false;
		break;
	}
}
return true;
}

if(online($connection))
{
//Your server is online..
}
else
{
//It's not
}

 

But it still takes the same amount of time.

Link to comment
Share on other sites

well, that code wouldn't work anyway. you declared $start outside of the function without making it global:

 

$start = time();

function online($connection)
{

global $start;

 

 

put this code at the top of your script:

<?php 
   $mtime = microtime(); 
   $mtime = explode(" ",$mtime); 
   $mtime = $mtime[1] + $mtime[0]; 
   $starttime = $mtime; 
;?> 

 

 

 

 

then put this where you want it:

<?php 
   $mtime = microtime(); 
   $mtime = explode(" ",$mtime); 
   $mtime = $mtime[1] + $mtime[0]; 
   $endtime = $mtime; 
   $totaltime = ($endtime - $starttime);
   

function online($connection)
{

global $totaltime;

while(!$connection)
{
	if($totaltime >= 2)
	{
		return false;
		break;
	}
}
return true;
}

if(online($connection))
{
//Your server is online..
}
else
{
//It's not
}
   
;?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.