|
Posted by Toby A Inkster on 09/04/07 08:02
Marijn wrote:
> private function __getDatabaseConnection(){
> if (!$this->__databaseConnection) {
> $this->__databaseConnection = new DatabaseFactory();
> };
> return($this->__databaseConnection);
> }
> }
I certainly prefer this.
> By the way, another small convention question: Should you terminate
> control structures with a semicolon?
No. In fact, in this particular case, you don't even need the braces.
Using my own preferred coding style, it would be:
private function __getDatabaseConnection ()
{
if (!isset($this->__databaseConnection))
$this->__databaseConnection = new DatabaseFactory();
return $this->__databaseConnection;
}
By the way, you shouldn't name your functions with a double-underscore.
Functions that start with a double-underscore are reserved for future use
as "magic" functions (e.g. __construct, __call, __get, __autoload, etc).
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 75 days, 11:36.]
TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/
Navigation:
[Reply to this message]
|