473,396 Members | 2,102 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.

Recursive PHP?

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/
Dec 18 '05 #1
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
Dec 18 '05 #2
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

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 18 '05 #3
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/
Dec 18 '05 #4
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/
Dec 18 '05 #5
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
Dec 18 '05 #6
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
Dec 18 '05 #7
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/
Dec 19 '05 #8

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

Similar topics

19
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...
10
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. ...
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...
7
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 {
1
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...
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: 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
0
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...
18
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: ...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.