In PHP, What is the difference between declaring methods inside class like
public function VS function
For example:
public function contact()
{
$data['header'] = "Contact";
$this->load->view('admin/admin_contact', $data);
}
VS
function contact()
{
$data['header'] = "Contact";
$this->load->view('admin/admin_contact', $data);
}
Is it better practice to use public function or function and why?
Methods declared with any explicit visibility keyword is best practice. It looks and feels better and it doesn’t confuse people.
visibility.