PHP - deciding a function to fire without condition
pI have developed a new technique for my future programs to decide which
function is to be fired without if/else statements. It is to create an
associative array of functions and call them by a function according to
argument given. I think actual representation will be better./p
precode$_functions = array( names =gt; function() { .... }, orders =gt;
function() { .... } ); function doLoad($toLoad) { global $_functions;
$_functions[$toLoad](); } /code/pre pNow, a user has to write only:/p
precodedoLoad(names); /code/pre pwherever they want to print out names./p
pstrongQuestion:/strong/p pI will be creating a script and it will be
distributed among other fellas to use it their way./p pIs it better to do
it like this way for my script? Is there any drawbacks of this
technique?/p
No comments:
Post a Comment