CodeIgniter Forums
public function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: public function (/showthread.php?tid=65883)



public function - davy_yg - 08-05-2016

Hello,

I have a quick question regarding the function of writing "public" in the beginning of function.

What is the difference between writing:


models/Mpages.php


PHP Code:
public function login() {}

and

function 
login() {} 



RE: public function - Ivo Miranda - 08-05-2016

It's the same. The first one is more explicit and you should use it for better clarity.

For more info:
http://stackoverflow.com/questions/4361553/php-public-private-protected


RE: public function - PaulD - 08-05-2016

http://php.net/manual/en/language.oop5.visibility.php


RE: public function - marksman - 08-05-2016

in writing inside the class you have to specify whether it is public, static, or private.