Empty Variables
Part of the Fundamentals section of Coddy's PHP journey — lesson 11 of 71.
In PHP, the null value is a special value that represents "nothing" or "no value". It's like an empty box - it exists, but there's nothing inside it. For example:
$userPreference = null;In a real scenario you could use null to indicate that something was not initialized yet.
For example:
$score = null // Score hasn't been calculated yet
$name = null // Name hasn't been entered yetCheat sheet
The null value represents "nothing" or "no value" - useful for indicating uninitialized or missing data:
$userPreference = null;
$score = null; // Score hasn't been calculated yet
$name = null; // Name hasn't been entered yetTry 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 Operators