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 ? $product1 is an instance of class Komik. $produk1 = new Komik(“Naruto”, “Masashi Kishimoto”, “Shonen Jump”, 30000, 100); And by echo $produk1->harga; it prints out 500 and not an
Tag: visibility
Call private methods and private properties from outside a class in PHP
I want to access private methods and variables from outside the classes in very rare specific cases. I’ve seen that this is not be possible although introspection is used. The specific case is the next one: I would like to have something like this: This method should be able to be injected in the code like this: (this is just