What is the difference between StudlyCaps and CamelCase?

后端 未结 4 1090
悲&欢浪女
悲&欢浪女 2021-02-01 15:59

PSR suggests, method names MUST be declared in camelCase and class names MUST be declared in StudlyCaps.

4条回答
  •  梦毁少年i
    2021-02-01 16:32

    CamelCase is where the first letter of each sub-word in a name is capitalised. The first letter of the whole name can be upper or lower case, and is generally (always?) lower case in programming.

    StudlyCaps is a little weird. There are capital letters, but they can be at any letter according to some rule, not just the beginning of a sub-word. The classic example is (was) HoTMaiL.

    My understanding of the PSRs is that their intention is that each sub-word should be capitalised in both instances, with classes having an initial upper-case letter and methods an initial lower-case letter.

提交回复
热议问题