Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

diff between public and not function

what is the different between

public function something()
{

}

and

function something()
{

}

any explaination? which more better?

like image 692
rails_noob Avatar asked Sep 05 '26 11:09

rails_noob


1 Answers

PHP/4 did not implement visibility yet. When it was added in PHP/5, a missing visibility keyword was made synonym of public so existing code would not break.

If it's legacy code, my advice is to leave it as is until you have the chance to review the code and pick an adequate visibility. If it's new code, you should make it explicit.

like image 84
Álvaro González Avatar answered Sep 08 '26 00:09

Álvaro González



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!