You are here: Re: window.setTimeout equivalent in PHP? « PHP Programming Language « IT news, forums, messages
Re: window.setTimeout equivalent in PHP?

Posted by Jerry Stuckle on 09/03/07 12:42

Csaba Gabor wrote:
>> However, getting a PHP function to run on a timed basis (without any
>> delay loops) does not seem so easy, which leads to my question: Is
>> there a straightforward way of implementing a PHP equivalent to
>> window.setTimeout?
>>
>> In other words, I'd like to be able to kick off a PHP function after a
>> certain amount of time has elapsed. One possible way to think of this
>> is an event driven Sleep. One way to do this is to ensure that I have
>> a copy of IE up, and then I can use IE's window's own .setTimeout to
>> tie it into PHP, but this is a bit messy not to mention that I don't
>> like the IE requirement.
>>
>> Thanks for any ideas,
>> Csaba Gabor from Vienna
>
> My question was about CLI PHP (Command Line Interface or CLIent side
> php), and not server side processing. The analogy to
> window.setTimeout was because many people are familiar with it.
>
> To repeat, the question is: What is the cleanest way of implementing a
> PHP equivalent to window.setTimeout (on CLI PHP)?
>
> As mentioned in the original post, it is strightforward to do event
> driven programming in php using com_event_sink and com_message_pump.
> PHP is happy with client side, event driven processing of COM
> objects. Furthermore, a (client side) setTimeout can be implemented
> by using IE's own window.setTimeout to call into PHP (presumably,
> Excel's Application.OnTime could serve the same purpose), but I was
> hoping for a cleaner method.
>
> How am I using this? Consider that I might like to use IE to navigate
> a certain sequence of pages. So I have the following, right?:
> $ie = new COM("InternetExplorer.Application");
> $ie->visible = true; // during development
> $ie->Navigate2 ("http://somewhere");
>
> Now normally, one would then have a loop to the tune of
> while ($ie->readyState<3) { com_message_pump(200); }
> In other words, we wait until ie has loaded the page.
>
> However, I'd like to do this on an event driven basis. That is to
> say, when http://somewhere has loaded, I'd like to automatically kick
> off a function somewhereHasLoaded($ie). And this is fairly
> straightforward by trapping on $ie's downloadComplete event.
>
> However, this isn't the full story, because suppose that something
> happens and ie doesn't finish loading. That's why there's always a
> timeout for these types of situations. For the loop situation, it's
> pretty clear:
> while ($ie->readState<3 && time()<$timeoutTime) {
> com_message_pump(200); }
>
>
> However, the event driven situation has a problem. I need to be
> signalled both upon the downloadComplete event and also, and upon a
> timeout. Hence the question of the cleanest way to do it.
>
>
> On Sep 3, 12:51 am, Csaba Gabor <dans...@gmail.com> wrote:
>> Is there a straightforward way of implementing a PHP equivalent to
>> window.setTimeout?
>
> ...
>

(Top posting fixed)

OK, you're using the wrong tool for this. PHP is server side, not
client side, and has no idea what happens at the client. For instance,
it doesn't know when the client has completed loading the page. All it
knows is that the page has finished executing on the server and passed
the output onto the web server.

You might look into javascript, for instance, which runs on the client.
It can handle the page loaded. But it can't handle a timeout if the
page doesn't get loaded. No one can, AFIAK.

But what are you trying to accomplish with all of this?

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация