How you visible private and protected method and variable out side class is called encapsulation.

class Encap {
public $name;
private $id;
protected $tax;

public function userId() {
return $this->id = 786;
}
}
$obj = new Encap();
echo $obj->userId();