Function declaractions follow the "one true brace" convention:
function fooFunction($arg1, $arg2 = '') { if (condition) { statement; } return $val; } |
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example:
function connect(&$dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$dsn; } else { $dsninfo = DB::parseDSN($dsn); } if (!$dsninfo || !$dsninfo['phptype']) { return $this->raiseError(); } return true; } |
HIVE: All information for read only. Please respect copyright! |