PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Assured99
Forum Commoner
Posts: 81 Joined: Wed Jul 12, 2006 11:48 am
Location: California
Post
by Assured99 » Sun Sep 10, 2006 5:27 pm
Im trying to create a script that will Factor a Number,
here is what i have so far but i keep getting this error
unexpected T_INC, expecting ')' on Line 5
Code: Select all
<?php
$num = '14' ;
$counter = '1';
function factor($num , $counter++ ){
"$num / $counter++";
}
Factor();
?>
Can any one point me in the right direction with finishing this script???
~Assured99
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Sep 10, 2006 5:40 pm
you cannot increment the parameter in the function declaration
function factor($num , $counter++ ){
What's the next line supposed to do?
Assured99
Forum Commoner
Posts: 81 Joined: Wed Jul 12, 2006 11:48 am
Location: California
Post
by Assured99 » Sun Sep 10, 2006 5:46 pm
Im really just trying to get it to display all the factors of a number. so im confused on where to go next.
~snapple
Assured99
Forum Commoner
Posts: 81 Joined: Wed Jul 12, 2006 11:48 am
Location: California
Post
by Assured99 » Sun Sep 10, 2006 5:48 pm
something like this mabye????
Code: Select all
<?php
$num = '14' ;
$counter = '1';
function factor($num , $counter){
"$result = $num / $counter++";
echo "$result";
}
Factor();
?>
~Snapple
sweatje
Forum Contributor
Posts: 277 Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA
Post
by sweatje » Sun Sep 10, 2006 7:56 pm
Once you get around to actually writing the logic, this
blog post may help some.