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

Recommended Answers

All 3 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.