My class is like this:
<?php
class ExampleClass{
private $example_property = false;
public function __construct(){
$this->example_property = function() {
$this->example_property = 1;
return $this->example_property;
};
}
public function get_example_property(){
return $this->example_property;
}
}
$example = new ExampleClass();
echo $example->get_example_property();
Property $example_property
must be false
until you call it, then, the first time it is called, I want to assign 1
to it. What's wrong with my code?
Error: Error Object of class Closure could not be converted to string on line number 20
.