Monday, 19 August 2013

All functions in class

All functions in class

I am thinking about create one or many classes that house a collection of
functions. I know I can add easy scripts to include all function files
individually but I think it would be better to just create class's that
match the group of functions and then house them there. Then I could use
spl_autoload_register to load that group when needed (lazy load). This
should limit the amount of overall functions I include maybe?
Example Code:
class uberFunc {
function recursive_array_search($needle,$haystack) {
foreach($haystack as $key=>$value) {
$current_key=$key;
if($needle===$value OR (is_array($value) &&
recursive_array_search($needle,$value) !== false)) {
return $current_key;
}
}
return false;
}
}
Then call something like `uberfunc::recursive_array_search($needle,$haystack)

No comments:

Post a Comment