Answer the question
In order to leave comments, you need to log in
How to return the state of an object?
Explain with examples
Simple class
class Example {
public $variable;
public function foo() {
//some code
}
}
$obj = new Example();
$obj->variable = "Переменная";
//some code
public function method(Example $obj) {
//some code
}
//some code
Answer the question
In order to leave comments, you need to log in
$obj = new Example();
$obj->variable = "Переменная";
$anotherobj = new AnotherObj;
$anotherobj->method($obj);
If you are not sure, you can explicitly specify the transfer of an object by reference
$obj = new Example();
$obj->variable = "Переменная";
$anotherobj = new AnotherObj;
$anotherobj->method(&$obj);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question