Do PHP support recursive calling, like this:
function some_func ($some_arg)
{
$count = 0;
// some code
while (<some condition>)
{
if (<some condition>)
{
$count += some_func ($some_arg);
} else {
++$count;
}
}
return $count;
}
--
Jørn Dahl-Stamnes http://www.dahl-stamnes.net/dahls/ 7 1298
Jørn Dahl-Stamnes said the following on 18/12/2005 09:42: Do PHP support recursive calling, like this:
function some_func ($some_arg) { $count = 0; // some code while (<some condition>) { if (<some condition>) { $count += some_func ($some_arg); } else { ++$count; } } return $count; }
Did you not think to just try it out?
--
Oli
Oli Filth wrote: Jørn Dahl-Stamnes said the following on 18/12/2005 09:42: Do PHP support recursive calling, like this:
function some_func ($some_arg) { $count = 0; // some code while (<some condition>) { if (<some condition>) { $count += some_func ($some_arg); } else { ++$count; } } return $count; }
Did you not think to just try it out?
Yes, I did and it did not seem to work. I asked becasue maybe there was some
hack etc that I needed to do before it worked...
--
Jørn Dahl-Stamnes http://www.dahl-stamnes.net/dahls/
Andy Hassall wrote: On Sun, 18 Dec 2005 10:42:16 +0100, Jørn Dahl-Stamnes <ne***********@REMOVEdahl-stamnes.net> wrote:
Do PHP support recursive calling
http://www.php.net/manual/en/language.functions.php
A newer version of my local version of the document. It say that it should
be possible, but this seems not to work on my server (PHP 4.3.9). Do I need
a newer version of PHP?
--
Jørn Dahl-Stamnes http://www.dahl-stamnes.net/dahls/
Jørn Dahl-Stamnes said the following on 18/12/2005 18:29: Oli Filth wrote:
Jørn Dahl-Stamnes said the following on 18/12/2005 09:42:
Do PHP support recursive calling, like this:
function some_func ($some_arg) { $count = 0; // some code while (<some condition>) { if (<some condition>) { $count += some_func ($some_arg); } else { ++$count; } } return $count; }
Did you not think to just try it out?
Yes, I did and it did not seem to work. I asked becasue maybe there was some hack etc that I needed to do before it worked...
Ah well, you didn't say that! If you're not specific, you usually get a
condescending answer on Usenet.
What doesn't work? Did you get any error messages, etc.?
--
Oli
On Sun, 18 Dec 2005 19:31:57 +0100, Jørn Dahl-Stamnes
<ne***********@REMOVEdahl-stamnes.net> wrote: Andy Hassall wrote:
On Sun, 18 Dec 2005 10:42:16 +0100, Jørn Dahl-Stamnes <ne***********@REMOVEdahl-stamnes.net> wrote:
Do PHP support recursive calling
http://www.php.net/manual/en/language.functions.php
A newer version of my local version of the document. It say that it should be possible, but this seems not to work on my server (PHP 4.3.9). Do I need a newer version of PHP?
No, recursive functions have always worked.
For a more helpful reply, post more information.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Andy Hassall wrote: On Sun, 18 Dec 2005 19:31:57 +0100, Jørn Dahl-Stamnes <ne***********@REMOVEdahl-stamnes.net> wrote:
Andy Hassall wrote:
On Sun, 18 Dec 2005 10:42:16 +0100, Jørn Dahl-Stamnes <ne***********@REMOVEdahl-stamnes.net> wrote:
Do PHP support recursive calling
http://www.php.net/manual/en/language.functions.php
A newer version of my local version of the document. It say that it should be possible, but this seems not to work on my server (PHP 4.3.9). Do I need a newer version of PHP?
No, recursive functions have always worked.
After I saw the example in the document above, I tested it and found out
that it did work.
So after looking into my code again, I found a small error that resulted in
an incorrect return argument, which in the first place looked like it did
not work.
Thanks.
--
Jørn Dahl-Stamnes http://www.dahl-stamnes.net/dahls/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carlos Ribeiro |
last post by:
Hello all,
Here I am using some deeply nested, tree-like data structures. In some
situations I need to traverse the tree; the old-style way to do it is
to write a recursive method on the node...
|
by: Steve Goldman |
last post by:
Hi,
I am trying to come up with a way to develop all n-length permutations of a
given list of values. The short function below seems to work, but I can't
help thinking there's a better way. ...
|
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...
|
by: Jon Slaughter |
last post by:
#pragma once
#include <vector>
class empty_class
{
};
template <int _I, int _J, class _element, class _property>
class RDES_T
{
|
by: Jon Slaughter |
last post by:
I've managed to put together a template class that basicaly creates a
recursive tree that lets you easily specify the "base" class of that tree
and and ending notes and lets you stop the recursive...
|
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. ...
|
by: seberino |
last post by:
I'm a compiler newbie and curious if Python grammar is able to
be parsed by a recursive descent parser or if it requires
a more powerful algorithm.
Chris
|
by: champ1979 |
last post by:
I wrote an algorithm to get all the relatives of a person in a family tree. I'm basically getting all the users from the DB and am doing the recursive logic in code, so that there is only 1 call...
|
by: Just Another Victim of the Ambient Morality |
last post by:
Is pyparsing really a recursive descent parser? I ask this because
there are grammars it can't parse that my recursive descent parser would
parse, should I have written one. For instance:
...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |