View Single Post
Old 09-11-2006, 06:15 AM   #3 (permalink)
Itsacon
Junior Member
 
Itsacon's Avatar
 
Join Date: Sep 2006
Location: Sector ZZ9 Plural Z Alpha
Posts: 34
Send a message via ICQ to Itsacon
Default Re: Number Factoring PHP Script HELP!!!

Aside from the functional errors moriakaice, pointed out, a simple explanation of the error you're getting:
PHP Code:
function factor($num $counter++ ) 
is not allowed.
In the same way that
PHP Code:
function factor($num $counter=$someothervar
wouldn't be allowed.
default values for function parameters need to be constant, they will NOT be evaluated at runtime.

Have a look at the PHP manual entry on function arguments for more details.

A little addition to moriakaice's script: I'd add a check after each increment operation to make sure $counter isn't zero. Calling the function with factor($num, -1); will terminate the script in a quick and dirty way...
__________________
"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams
Itsacon is offline   Reply With Quote
Sponsored Links