0

I cant decide if it is appropriate to use user defined functions for every single action in a page..or it somehow may slow the work? I can alternatively make different php files instead of functions,,and they will do the same thing depending on values of some variables, but i would like to do it the right way. Maybe making functions is better? how you think?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by kracko
1

If it is simpler (less code) then it is probably better. If you need to do the same thing multiple time using different parameters then a function would seem to be the way to go. Unless there is a lot of complex / extra code in the function to make sense of the input parameters and what you need to do with them (versus customized modules for each type of parm), then it won't have any performance impact.

0

If it is simpler (less code) then it is probably better. If you need to do the same thing multiple time using different parameters then a function would seem to be the way to go. Unless there is a lot of complex / extra code in the function to make sense of the input parameters and what you need to do with them (versus customized modules for each type of parm), then it won't have any performance impact.

thanks a lot) just one more question. If I need to do the same thing multiple times.. i can also require corresponding php file multiple times.. What do you think..are functions still a better way?

1

Hi kracko,

If you need to run code multiple times on the same page, then a function would probable be the best approach, you can just call the function when needed. If you need to run the code multiple times on different pages, then the require (or include) approach would serve you better.


Zagga

Votes + Comments
Excellent!
0

hi kracko,

if you need to run code multiple times on the same page, then a function would probable be the best approach, you can just call the function when needed. If you need to run the code multiple times on different pages, then the require (or include) approach would serve you better.


Zagga

thanks! A lot!

This question has already been answered. 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.