PHP Accessing Properties and Methods

With PHP OOP, you can declare properties and methods to be public, private and protected. Depending on the circumstances, you will have the option to choose the ideal method for which to control properties and functions. All methods and properties can be defined within their class.

Public
Public properties or methods can be accessed anywhere in various classes

Public variables:

public $variable;
public $variable2;

Public function:
public function myfunction(){
}

Private
Private Private properties and methods can be accessed only in the class where it is declared. They cannot be accessed by parent or children classes.

Private variables:
private $variable;
private $variable2;

Protected
Protected properties and methods can be accessed in the class where it is declared and child classes.

Protected variables:
protected $variable;
protected $variable2;