6.11. Calling Variable Functions6.11.2. SolutionUse variable variables:
6.11.3. DiscussionIf you have multiple possibilities to call, use an associative array of function names:
This code takes the command name from a request and executes that function. Note the check to see that the command is in a list of acceptable command. This prevents your code from calling whatever function was passed in from a request, such as phpinfo( ) . This makes your code more secure and allows you to easily log errors. Another advantage is that you can map multiple commands to the same function, so you can have a long and a short name:
6.11.4. See AlsoRecipe 5.5 for more on variable variables.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|