474,042 Members | 7,660 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 2720
<ba************ *****@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
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.com wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.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***@bhg byrzcv.arg)
Jan 16 '07 #4
On Jan 16, 6:42 am, balakrishnan.di n...@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_t ime 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.com wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.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***@bhg byrzcv.arg)
Jan 16 '07 #7
"P Pulkkinen" <pe************ *************@P OISTATAMA.elisa net.fiwrote in
message news:be******** *********@reade r1.news.saunala hti.fi...
>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_t ime 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***@bhg byrzcv.arg)
Jan 16 '07 #8

<ba************ *****@gmail.com kirjoitti
viestissä:11*** *************** ***@v45g2000cwv .googlegroups.c om...
"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
15002
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
4
8419
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 now: <script language="JavaScript">
1
2544
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 works well until I try to enclose these functions into a class like structure ie: function dTimer(div){ //Insert the Javascript Code Below startTimer(); }
10
2326
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 values. Works in both ie and firefox. Parameters styleType = top | left | width | height toNumber = the new value of the style then you pass in as many ids as you would like.
6
10936
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 { setTimeout("document.getElementById('mydiv').style.length='10px';",1000);
28
4387
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
2525
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(); } </script>
2
1864
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 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script...
5
1556
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 cases (when mouse keeps moving) don't trigger that function. Can any one tell how to implement this?
0
10543
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11601
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12014
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11138
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6833
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.