Cod: Selectaţi tot
<?php
class A {
private $value = 1;
public function getVal() {
return function() { return $this->value * 2; };
}
}
$a = new A;
echo $a->getVal(); // 2
?>
Cod: Selectaţi tot
<?php
class A {
private $value = 1;
public function getVal() {
return function() { return $this->value * 2; };
}
}
$a = new A;
echo $a->getVal(); // 2
?>
Cod: Selectaţi tot
class A {
private $value = 1;
public function getVal() {
function fun($param) { return $param * 2; };
return fun($this->value);
}
}
$a = new A;
echo $a->getVal(); // 2