On Mon, 2010-11-22 at 15:26 -0800, David Harkness wrote:
> On Mon, Nov 22, 2010 at 3:05 PM, Richard Quadling <rquadl...@gmail.com>wrote:
> > Would it be overboard to use a namespace? Aren't namespaces handled by
> > the autoloader? If not autoload(), how about spl_autoloading?
> >
> Autoloading is for determining the path and filename where a named item is
> defined. Namespaces only give you the path. Even with namespaces, you'd
> still need to require the files that contain the functions. Plus you'd also
> need to use the namespace everywhere you use the function because you cannot
> alias functions--only classes. :(
> David

can I maybe make a suggestion?   If I have been following this
correctly, it seems as if the OP has a bunch of "non specific class"
functions, that he doesn't want in 1 big gigantic file, and include that
one huge file ALL the time...   what if the OP put some naming
conventions into the function names, and then did some kind of error
trapping on the function calls, and if the function does not exist (yet)
then call some other function to rip apart the name of the function that
was called, and then include that "file"?   I am just offering some kind
of hypothetical solution, and off the top of my head can't think exactly
how it could be accomplished.

you could always wrap all your "non class"/"custom" functions in a

function checkFunction($file, $function, $args)
  $filename = "./function_{$file}.php";
    return 'function file not exist';

  if(function_exists($file .'_'. $function))
    return call_user_func_array($file .'_'. $function, $args);
    return "Function: {$function}() does not exist";

  return 'Fire and brimstone coming down from the skies! Rivers and seas
boiling! Forty years of darkness! Earthquakes, volcanoes... The dead
rising from the grave! Human sacrifice, dogs and cats living together...
mass hysteria!!';

$temp = checkFunction('test', 'somefunction', array('var1', 'var2'));

then create the functions file- functions_test.php that holds all the
functions you would "group" together... 

function test_somefunction($var1, $var2, $var3 = '')
        return $var1 .' - '. $var2;

This is just a thought, and yeah, it would require some rewrites, and
some forward thinking...  but could solve your issue... maybe


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to