+ 2
What is this -> in PhP?
-> was not there in the lessons xD
3 ответов
+ 1
-> is not related to arrays, it's for object scope.
class doSomething{
private $correctAnswer;
function somethingDone($somethingHappened){
$this->correctAnswer = $somethingHappened;
}
}
$ds = new doSomething();
$ds->somethingDone(true);
+ 1
Ok thanks,
0
Whenever you want to use an object’s method or property, you need to use the -> operator.
e.g.:
$company->name = 'Acme';
$company->getName();