473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP recursive function

18
Hi all, I need a PHP script that checks the creation date of a file each 5 seconds, if creation date is changed it reload the page via javascript
I' ve tried with:

function verificaData($dataCreazione)
{
flush();
sleep(5);
flush();
$datacreTemp= filectime('SiSeFi/SiSeFi.png');
if ($dataCreazione==$datacreTemp)
{
verificaData($datacreTemp);
}
else
{
echo'<script>window.location.reload();</script>' ;
}
}
I just call the function after the <body> tag.
Why it doesn't work?
What wrong with this?

Thanks.
Feb 5 '08 #1
5 3390
MarkoKlacar
296 Expert 100+
Hi,

I fail to see why this funtion has to be recursive, if the page that's calling this function is to be open constantly you could probably just to with a loop of some sort.

I don't know the context or the use of you php file, but perhaps you could look at the filemtime function.

Hope this helps..
Feb 6 '08 #2
Ciri
18
Hi,

I fail to see why this funtion has to be recursive, if the page that's calling this function is to be open constantly you could probably just to with a loop of some sort.

I don't know the context or the use of you php file, but perhaps you could look at the filemtime function.

Hope this helps..

Ok, thanks. I've tried your way:
<?
$creationTime=filemtime('myPicture.png')
while(true)
{
flush();
sleep(5);
if ($creationTime!=filemtime('myPicture.png')
{
echo'<script language=javascript> window.location.reload();</script>';
}

}
?>

It seems to work only for one user per time.
If I open only one instance of the browser it's perfect but if I open a second window on the same page both apps stops working and freeze the browser!
Any suggestion?

Thanks.
Feb 6 '08 #3
MarkoKlacar
296 Expert 100+
Hi,

What happens if you remove flush()?
Feb 6 '08 #4
Ciri
18
I've tried removing the flush(): the page never loads.
This is the complete code of the page:

<html>
<head>
</head>
<body>
<img src="SiSeFi/SiSeFi.png" style="background-image:url(SiSeFi/SiSeFi_bckgrd.jpeg)" alt=""/>

<?
$dataCreazione=filectime('SiSeFi/SiSeFi.png');
while ($dataCreazione==filectime('SiSeFi/SiSeFi.png'))
{
sleep(5);
}

?>

</body>
</html>

Could you help me please understaing why it doesn't work?

Thank you all guys.
Feb 6 '08 #5
MarkoKlacar
296 Expert 100+
Hi,

Don't know if this solves you problem but you while statement looks different now(the names are wrong i know..)
[PHP]if ($creationTime==filemtime('myPicture.png')[/PHP]
you use to have
[PHP]if ($creationTime!=filemtime('myPicture.png')[/PHP]

perhaps you need to look at that...

Get back to us if you need more help, maybe I can provide you with an alternative solution if it'a an option for you...

Good Luck..
Feb 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
OK: Purpose: Using user's input and 3 recursive functions, construct an hour glass figure. Main can only have user input, loops and function calls. Recursive function 1 takes input and displays...
4
by: Nicolas Vigier | last post by:
Hello, I have in my python script a function that look like this : def my_function(arg1, arg2, opt1=0, opt2=1, opt3=42): if type(arg1) is ListType: for a in arg1: my_function(a, arg2,...
4
by: Victor | last post by:
Hello, I've got a situation in which the number of (valid) recursive calls I make will cause stack overflow. I can use getrlimit (and setrlimit) to test (and set) my current stack size. ...
9
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
41
by: Harry | last post by:
Hi all, 1)I need your help to solve a problem. I have a function whose prototype is int reclen(char *) This function has to find the length of the string passed to it.But the conditions...
10
by: AsheeG87 | last post by:
Hello Everyone! I have a linked list and am trying to include a recursive search. However, I am having trouble understanding how I would go about that. I don't quite understand a recursive...
4
by: ThEoNeAnDOnLy | last post by:
I recently had an issue with my recursive project in class. Here is the code. // Recursion.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include...
3
by: from.future.import | last post by:
Hi, I encountered garbage collection behaviour that I didn't expect when using a recursive function inside another function: the definition of the inner function seems to contain a circular...
3
by: Davy | last post by:
Hi all, Sometimes I need to pass same parameter in recursive function. From my point of view, the style is redundant, and I don't what to use some global style like self.A, self.B, Is there any...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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
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...
0
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,...
0
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...

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.