--- Start ---
class Something
{
public function __construct()
{
// Oops, forgot to initialise $this->something...
}
public function f()
{
return $this->something;
}
private $something;
}
error_reporting(E_ALL);
$something=new Something;
echo $something->f()+10; // Prints "10".
If you can't trust the return values of your methods, I would use:
$var = $something->f();
if($var!==NULL){
echo $var+10; // Prints "10".
}
However, its crap like this that reminds me why I don't use PHP OOP for
all my code. I can find no non-OOP code that behaves this way. Even my
favorite PHP trick, using settype() to initialize vars, does not set the
var to NULL.
--
Brian Moon
-------------
http://dealnews.com/
Its good to be cheap =)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php