• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Draft / Code Standards Naming Styles

Code Standards Naming Styles

Last updated on July 5, 2021 by Sal Ferrarello

snake_case_names

Each word is separated by an underscore (_) and uses only lowercase letters. Named because it looks like a snake.

Use Cases for snake_case

Variables, hooks, function names, and method names in WordPress PHP standards.

SCREAMING_SNAKE_CASE

Each word is separated by an underscore (_) and uses only uppercase letters. All uppercase letters is often interpreted as SHOUTING or SCREAMING.

Use Cases for SCREAMING_SNAKE_CASE

PHP constants and class constants when following PSR-12, PSR-2, or WordPress PHP standards.

kabob-case-names

Each word is separated by an dash (-) and uses only lowercase letters. Named because it is reminiscent of a kebab, which is food cooker on a skewer.

kabob-case usage

Kabob-case is very popular for CSS classes (<p class="first-name">), though some more complex systems (notably BEM use a mix of dashes (-) and underscores (_)) – perhaps we could call this snake-kebab_case.

Kabob-case is also very popular for naming files, e.g. my-file.pdf.

camelCaseNames

Each word, with the exception of the first word, starts with an uppercase letter while the remaining letters in each word are lowercase. Named because of the visual similarity to a camel with hump(s).

camelCase usage

PHP function and method names when following PSR-12, PSR-2, or PSR-1.

PascalCaseNames

Each word, including the first word, starts with an uppercase letter while the remaining letters in each word are lowercase. Named because this naming standard is used in the programming language Pascal. Also known as UpperCamelCase.

Sometimes referred to as StudlyCaps, though technically STuDLycAPs use a variety of capital letters but not necessarily the first letter of each word.

PascalCase Usage

PHP classnames when following PSR-12, PSR-2, or PSR-1.

Camel_Caps

Each word should start with a capital and words should be separated by an underscore, e.g. Sub_Domain.

Camel_Caps usage

The WordPress coding standards issue about namespaces, is one of the few places I’ve seen Camel_Caps discussed.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Programming Tagged With: code standards

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in