Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 28th, 2004, 01:20 PM
Authorized User
 
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default recursion

recursion.html

<html>
<head></head>
<body>
<form method=get action="recursion.php">
I would like to know the factorial of
<input name="value" type="text">
<input type=submit>
---------------------------------------
recursion.php
<?php
function recursion($value)
{ if($value<=1)
   return 1;
  else
   return $value*recursion($value-1);
}
echo"The factorial of ".$value." is ".(recursion($value));
?>
--------------------------

for the recursion.php page where do i use the $_GET['value'] call and where do i just leave it as $value.

thanks


 
Old June 28th, 2004, 03:58 PM
Authorized User
 
Join Date: Jun 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you could just use $value = $_GET['value'] at the top, above the function recursion($value) line.
but, really, you should be able to place it almost anywhere, just as long as it's set before it's used in the echo statement.

after you've set the value for $value, you should be able to call it without using $_GET().





Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt recursion (need help ) newbiexslt XSLT 4 March 26th, 2007 10:59 AM
recursion in XSL jekkos XSLT 8 January 2nd, 2007 06:16 PM
Recursion lincsimp XSLT 1 August 16th, 2005 04:26 PM
recursion yui0329 C# 6 April 28th, 2005 09:36 AM
Recursion shan9 JSP Basics 0 November 17th, 2004 09:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.