Its strange, i can do
<?php
$foo = function($a){
return $a;
};
var_dump($foo(123));
But in the scope of a classe if a do:
<?php
class Totalizer{
public $count;
public function __construct(){
$this->count = function($product){
return $product;
};
}
}
$foo = new Totalizer;
var_dump($foo->count(123));
Fatal error: Call to undefined method Totalizer::count()
My question is how can i do the same as the first snippet but in class scope?
ps: PHP 5.5