Category: PHP, javascript

A blog on PHP, JavaScript and more Amit Merchant · August 11, 2020 · ⋆ PHP One is to implement encapsulation which makes the class members available inside of the originating class only i.e. to hide data from the user of the class and can only be modified using public getter and setter methods.

As you can see, the privateMethod is a private method and if we want to access it outside of the class like so, we would get a fatal error.

And that is how you can access a private method of the class. Similarly, you can also access the private properties of the class but the only distinction here is instead of using ReflectionMethod, we’d need to used ReflectionProperty class like so.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners