Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $variavel = "valor";
- // com switch
- switch($variavel){
- case "a": break;
- case "b":break;
- default :
- }
- // workaround 1
- $functionStrategy = "func{$variavel}";
- $retorno = (function_exists($functionStrategy))?$functionStrategy():defaultStrategy();
- function a(){
- // estrategia A
- }
- function b(){
- //estrategia B
- }
- // workaround 2
- function Strategy($functionStrategy, &$retvalue)
- {
- include_once "{$functionStrategy}.php";
- $retvalue = (function_exists($functionStrategy))?$functionStrategy():defaultStrategy();
- }
- Strategy($variavel, $retorno);
Add Comment
Please, Sign In to add comment