8 Years
Discussion Span
Last Post by OS_dev

Look at the function definition and count them??? :icon_rolleyes:

Edited by Fbody: n/a


How do I find out the number of parameters passed into function?

You should be prepared for all scenarios. Even if you are trying some type of function overriding using the recommendation provided by as.bhanuprakash. This is not the way to do it anyway, php provides the ability to assign defaults to parameters and you should get into that habit. You should also look into passing in arrays and objects rather than passing any random number of parameters.

I feel that if you actually need to know the number of parameters coming into a function, that is a sign of poor design and will eventually have to be rewritten or subdivided into multiple functions because it has grown beyond what it was originally designed for.

Another thing to consider, the developer using the function should not have to know the inner workings of the function in order to be able to use it. He/she should be able to just pass in parameters and it just works.

Edited by OS_dev: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.