Wednesday, July 13, 2005

Code Smell

A


class Foo {

function getFoo() {
if ($this->foo) return $this->foo;
else return $_POST["foo"];

}

}

$f = new Foo();
print $f->getFoo();



OR

B


class Foo {

function getFoo() {
return $this->foo;
}

}

$f = new Foo();
print ($f->getFoo()) ? $f->getFoo() : $_POST["foo"];




Which is it, A or B and why?
Post a Comment