7

Question PHP folks. Is it a standard to write:
public function hair()?

Writing only:
function hair() is just the same thing to the above. It will default to "public" hair right? 🤔 maybe just a PSR-2 standard or for readability? Thanks!

Comments
  • 3
    In java default is default access specifier so in java those two ways are different.

    In php public is default access specifier so in php those two ways are same but it is good practice to always include it.
  • 1
    @Charon92 oh yes I remember. It should be detailed. Something like $prntscrn should be $printScreen for readability 👍
  • 4
    Although php is defaulted to public, it never hurts to explicitly state what it is.

    When a class contains private and public functions is easier for readability to know what is and isn’t public.
Add Comment