When to return values in PHP?

Paulzz

New Member
Given this ugly method:\[code\]public function convert_cell_value( $val, $type ){ if($type == 'String') { return $val; } elseif($type == 'Number') { if($val - intval($val) > 0) { return $val; } else { return intval($val); } } else { return $val; }}\[/code\]Now my ten billion $ question is: when i should return values (not in this method but any other like this) to apply the DRY principles and go for performance too. Or: There's something wrong with my thought about performance and it's nothing to do with it when i return some value immediately?Bonus question: Is there a simpler trick to get decimals than this?\[code\]if($val - intval($val) > 0){ return $val;}\[/code\]Thanks for your precious time,fabrik
 
Back
Top