I am trying to write a class and I run into two errors.
class Foo {
protected $count;
function __construct() {
$this->count = sizeof($_POST['some_key']);
}
static function get_count() {
echo $this->count; // Problem Line
}
}
$bar = new Foo;
$bar->get_count(); // Problem Call
The problem call is on the last line. using $this in the line with the "// Problem Line" comment generates a "Using $this when not in object context" error. Using "self::count" in place of "this->count" generates an "Undefined class constant error." What could I be doing wrong?