Menu
Coddy logo textTech

Naming Conventions

Part of the Fundamentals section of Coddy's PHP journey — lesson 9 of 71.

Naming conventions are a set of guidelines that developers follow to make their code more readable and maintainable. Different programming languages often have different naming conventions. In PHP, variables are written in camelCase - the first word starts with a lowercase letter, and subsequent words are capitalized with no spaces or separators.

When writing a variable name be descriptive and use meaningful words. Also remember that all PHP variables must start with a dollar sign $.

For example 

// Bad Naming
$user_name = "John";
$a = 10;
$b = "Hello";
$x = true;

// Good Naming
$age = 10;
$greeting = "Hello";
$isActive = true;
$userName = "John";

Cheat sheet

In PHP, variables follow camelCase naming convention - the first word starts with a lowercase letter, and subsequent words are capitalized with no spaces or separators.

Variable names should be descriptive and meaningful. All PHP variables must start with a dollar sign $.

// Good naming examples
$age = 10;
$greeting = "Hello";
$isActive = true;
$userName = "John";

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals