Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
2k views

Private property in parent class can be accessed and re-assigned through the instance of child class in PHP but protected one can't

I am very confused why $produk1->harga = 500; can still make a change (or re-assign the value 500) to private $harga property despite private $harga in class Produk has PRIVATE visibility ? $...
didaen's user avatar
  • 48
2 votes
1 answer
268 views

php inheritance with protected array property is giving me a serious headache

So I decided to make some classes in PHP so I can dynamically construct a menu bar using <ul>, <li> and <a> tags. Reason why is because I want to reuse this across projects. First the Blob ...
Jif's user avatar
  • 843
3 votes
2 answers
3k views

Visibility of __construct

If I have: abstract class AbstractSingleton { protected static $instance; public static function & getInstance() { if(null === static::$instance) static::$instance = new ...
Virus721's user avatar
  • 8,193