473,498 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there any function in PHP like setTimeout with same functionallity in javascript

hi frnds,

Is there any function in PHP like setTimeout with same
functionallity in javascript ..
Thing is, In php we have a function call settimeout for socket , But i
need the same functionallity of settimeout( ) fucntion of javascript in
PHP, Is that anything available in PHP. Is there plzzzzz reply me quick

Thank
Dinesh..

Jan 16 '07 #1
9 2696
<ba*****************@gmail.comwrote:
Is there any function in PHP like setTimeout with same
functionallity in javascript ..
Thing is, In php we have a function call settimeout for socket , But i
need the same functionallity of settimeout( ) fucntion of javascript in
PHP, Is that anything available in PHP. Is there plzzzzz reply me quick
Perhaps it would help people to help if you described the actual problem
that needs the solution.
Because if you compare php and javascript like that, there is usually a big
difference:

- javascript can manipulate page through dom object model and do things on
it again and again until user goes to another page.
- php _usually_ outputs a page, does some things in serverside and that's
it - goodbye, mypage!

Jan 16 '07 #2

Hi,

My exact problem is, i want to call a function for every 100
seconds in PHP code

Jan 16 '07 #3
<ba*****************@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
>
Hi,

My exact problem is, i want to call a function for every 100
seconds in PHP code

either make a cronjob to call it every nth second or make an infinitely
running daemon:
<?php

while(1){

// Do the magik

// Wait 100 seconds
sleep(100);
}

?>

a cronjob might be easier for the server to handle

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Jan 16 '07 #4
On Jan 16, 6:42 am, balakrishnan.din...@gmail.com wrote:
Is there any function in PHP like setTimeout with same
functionallity in javascript ..
Thing is, In php we have a function call settimeout for socket , But i
need the same functionallity of settimeout( ) fucntion of javascript in
PHP, Is that anything available in PHP. Is there plzzzzz reply me quick
You may want to read further documentation about pcntl
(especially pcntl_signal and pcntl_alarm).

--
Pierre

Jan 16 '07 #5
either make a cronjob to call it every nth second or make an infinitely
running daemon:
<?php

while(1){

// Do the magik

// Wait 100 seconds
sleep(100);
}

?>

a cronjob might be easier for the server to handle
I would like to know more about this, because this daemon solution is really
easy to do but is there some dangers with it:
- max_execution_time in php.ini
- is it causing stress to server.
Jan 16 '07 #6
hi Kimmo,

Thanks for ur solution, But the problem with this solution is,
After 100 seconds only , the page is getting displayed ,until nothing
is displayed ..
what I need is, while the counter is running in "sleep(100)" ,
other process should be performed concurrently
Is there any way for that

Thank
Dinesh...

Kimmo Laine wrote:
<ba*****************@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...

Hi,

My exact problem is, i want to call a function for every 100
seconds in PHP code


either make a cronjob to call it every nth second or make an infinitely
running daemon:
<?php

while(1){

// Do the magik

// Wait 100 seconds
sleep(100);
}

?>

a cronjob might be easier for the server to handle

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Jan 16 '07 #7
"P Pulkkinen" <pe*************************@POISTATAMA.elisanet.f iwrote in
message news:be*****************@reader1.news.saunalahti.f i...
>either make a cronjob to call it every nth second or make an infinitely
running daemon:
<?php

while(1){

// Do the magik

// Wait 100 seconds
sleep(100);
}

?>

a cronjob might be easier for the server to handle

I would like to know more about this, because this daemon solution is
really easy to do but is there some dangers with it:
- max_execution_time in php.ini
set_time_limit(0); should solve that, not sure thou.
- is it causing stress to server.
I don't know, haven't run any performance tests. Yet for some reason I'd
rather use cron for scheduling rather than this sort of solution.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Jan 16 '07 #8

<ba*****************@gmail.comkirjoitti
viestissä:11*********************@v45g2000cwv.goog legroups.com...
"But the problem with this solution is,
After 100 seconds only , the page is getting displayed ,until nothing
is displayed ..
what I need is, while the counter is running in "sleep(100)" ,
other process should be performed concurrently
Is there any way for that"

I want to ask:
Is this desired effect related to certain page of current user rather than
to your entire web service?

Why, because nowadays ajax-kind of things are applied to get up-to-second
content etc. to client side. More simply put, for example very small or
invisible iframe can be updated every n-second, with the helps of meta
refresh tag. That update call can do something on the server and then
something as well in the client, since other frames and main frame can dig
iframe's content. Even I have not yet applied this, but I see the point
anyway. It would very much simulate the work of timeout.

I have an impression that cron thing refers more to need to update or backup
the whole server content. It is running there on the server by itself,
calling on timely basis some 'pages' invisibly. (Please anyone, feel free to
correct me...)

Jan 16 '07 #9
C.
ba*****************@gmail.com wrote:
hi Kimmo,

Thanks for ur solution, But the problem with this solution is,
After 100 seconds only , the page is getting displayed ,until nothing
is displayed ..
what I need is, while the counter is running in "sleep(100)" ,
other process should be performed concurrently
Is there any way for that
Yes, but its not simple in PHP invoked from a webserver.

You've not really explained what you are trying to acheive.

Do you need a single thread of execution for the controlling process?
Must it be bound to a browser access? What are the failure modes? What
are the "other processes" to be performed concurrently? Should they
signal back to the browser? Should they run in a seperate process
group? Why does your script have to sleep while the other processes are
running? What have you tried?

C.

Jan 16 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14901
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
4
8373
by: Ken | last post by:
Hello I am trying to change the color of a font in a text box. I have been reading about and trying various examples found it this group, but still can't get it right. Here is where I am...
1
2507
by: CES | last post by:
All, I was wondering if someone could point me to a tutorial on creating & accessing functions from within a wrapper function. I've created a group of functions related to a timer event. All...
10
2271
by: Robert Skidmore | last post by:
Take a look at this new JS function I made. It is really simple but very powerful. You can animate any stylesheet numeric value (top left width height have been tested), and works for both % and px...
6
10892
by: Max | last post by:
Hi, I'm not exactly sure why this doesn't work. I'm basically just trying a simple approach at a slide down div. function slide_div { ...
28
4270
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
2488
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
2
1809
by: jasonchan | last post by:
I am trying to have a function start with a timer and then switch to another function. However, it is not working at all. Anyone know whats goin on? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
5
1527
by: john_woo | last post by:
Hi, If what I want from the on_mouse_move function is, trigger another function in two case: 1. when the mouse holds at same position for 1 second; 2. when the mouse fully stop; in other...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.