H
H
Hazrat Hajikerimov2016-07-27 21:40:59
PHP
Hazrat Hajikerimov, 2016-07-27 21:40:59

Intercepting an object property call?

Is it possible in php to intercept a property call?
Suppose the data object has a param property, by default it is empty, the first time you access param so that you can execute the def. method for filling it and in the future, if not empty, then do not call the filling method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kulikovsky, 2016-07-27
@hazratgs

Accessing a property via a getter/setter.

class Foo {
    private $param;

    public function getParam() {
        //... тут своя логика
        return $this->param;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question