Program to check:
<?php
trait MyTrait {
private $abc = 1;
public function increment(){
$this->abc++;
}
public function getValue(){
return $this->abc;
}
}
class MyClass {
use MyTrait;
public function incrementBy2(){
$this->increment();
$this->abc++;
}
}
$c = new MyClass();
$c->incrementBy2();
var_dump($c->getValue());
Output:
3
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ZhukovPeter
4 years, 10 months ago