The difference between public and invalid

What's the difference between

public function something()
{

}

and

function something()
{

}

any explanation? what's better?

+3
source share
1 answer

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

If this is an outdated code, I advise you to leave it as is until you have the opportunity to view the code and select the appropriate visibility. If this is new code, you must make it explicit.

+5
source

All Articles