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 Fletcher22 Nov 2023
Fatal error: Maximum execution time of 30 seconds exceeded in ...
When reloading a page, you may encounter the following error:Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/content/core/lib/Drupal/Core/{some file .php} on line n SolutionTo resolve this issue, you need to adjust the max_execution_time parameter in the php.ini...
Andrew Fletcher16 Nov 2023
Drupal and AWS - over 300 simultaneous database connections
The issue of over 300 simultaneous database connections in the context of AWS and Drupal can have several potential causes. Here are some common factors to consider:Server ConfigurationCheck your server configuration to ensure it can handle the expected number of simultaneous connections. This...