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...