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. PHP itself has no single convention for variable names. This course writes them in camelCase, the style used by frameworks such as Symfony and Laravel: the first word starts with a lowercase letter, and subsequent words are capitalized with no spaces or separators. Some projects, such as WordPress, use snake_case instead ($user_name).
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
$n = "John";
$a = 10;
$b = "Hello";
$x = true;
// Good Naming
$age = 10;
$greeting = "Hello";
$isActive = true;
$userName = "John";Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Comparison & Logical Operators
Comparison OperatorsEquality & IdentityLogical Operators Part 1Logical Operators Part 2Recap - Simple Logic2Variables and Data Types
NumbersStrings and QuotesBooleansNaming ConventionsRecap - Variable InitEmpty VariablesString ConcatenationGetting User InputCast to Different Types5Conditional Logic
If StatementIf - ElseThe Ternary OperatorNull Coalescing OperatorSwitch StatementRecap - Making Decisions3Basic Operators
Arithmetic OperatorsModulo OperatorExponentiation OperatorCombined AssignmentIncrement/DecrementOperator PrecedenceRecap - Simple CalculationsString OperatorsPractice on your own: Online PHP compiler