Skip to main content

Explain public, private, protected functions and variables inside a class in PHP.

I'll define a variable as a property

public method or property this is the default and can be accessed anywhere
protected method or property that can be accessed by the class that declared it or that inherits the class
private method or property that can only be accessed by the class that declared it

 

Related articles

Andrew Fletcher10 Sep 2024
Resolving PHP GD library issues in Drupal
IntroductionFor a while now, one persistent issue has been bugging me: a warning on Drupal's 'status report' page that reads:GD librarylibrary bundled (2.1.0 compatible)Supported image file formats: GIF, PNG.Unsupported image file formats: JPEG, WEBP.Check the PHP GD installation documentation if...
Andrew Fletcher31 May 2024
Connecting AWS S3 with Docker for Drupal 10
Recently, I encountered an issue where my local Docker environment refused to connect to AWS S3, although everything worked seamlessly in AWS-managed environments. This challenge was not just a technical hurdle; it was a crucial bottleneck that needed resolution to ensure smooth Drupal deployments...