Which is better coding style...

From: Date: Thu, 19 Apr 2001 17:57:17 +0000
Subject: Which is better coding style...
Groups: php.general 
Request: Send a blank email to php-general+get-49391@lists.php.net to get a copy of this message
Which is better? function blah() { switch( $bob ) { case 1: return "this"; case 2: return "that"; default: return "other"; } } function blah() { $retval = ""; switch( $bob ) { case 1: $retval = "this"; break; case 2: $retval = "that"; break; default: $retval = "other"; break; } return $retval; } In other words, is it good practice to exit out of a block (any block... not just switch; if, for, while) prematurely as demon- strated in the first example? Or should you do it as demon- strated in the second example? Chris

« previous php.general (#49391) next »