This is my simple implementation for custom data before return base on data type. In case I have many many type I want to know what is the best solutions for route to expected handler function. I don't want to use too muchswitch or if-else .Could you guys take a look at this code and tell me any suggestion, Is there any other way to handler data before return? Thank you
function A($data) {
}
function B($data) {
}
function bill($data) {
return converter($data, $type)
}
function converter($data, $type) {
if ($type == 'A')
{
return A($data);
} else {
return B($data);
}
}
p/s my English is not good . Sorry about that.
Aucun commentaire:
Enregistrer un commentaire