Skip to content

PHP Tutorial PHP Syntax and Output

PHP Case Sensitivity

Lesson 17 of 369 2 min read By Deepak Paswan Updated Oct 5, 2026

PHP is partly case-sensitive. That surprises many beginners, so learn the rule once.

Variables are case-sensitive

$name, $Name and $NAME are three different variables.

index.php
PHP
<?php
$name = "Sam";
$Name = "Tina";

echo $name . " and " . $Name;
Output
OUTPUT
Sam and Tina

A typo in a variable’s capital letter is a real bug, because PHP treats it as a brand-new variable.

index.php
PHP
<?php
$total = 100;
echo $Total;
Output
OUTPUT
Warning: Undefined variable $Total in /path/to/index.php on line 3

Function and keyword names are not

PHP does not care about case for built-in function names, class names or keywords such as echo and if.

index.php
PHP
<?php
ECHO strtoupper("hello");
echo STRTOLOWER("WORLD");
Output
OUTPUT
HELLOworld

This works, but nobody writes code this way. Always use the standard lowercase style so the code stays readable.

Constants are case-sensitive

Constants such as PHP_VERSION or your own MAX_SIZE are case-sensitive. By habit, we write them in capitals.

Quick summary

ThingCase-sensitive?
VariablesYes
ConstantsYes
Array keysYes
Function namesNo
Class namesNo
Keywords (echo, if, foreach)No
lightbulb
Pick one naming style
Use camelCase for variables and functions, PascalCase for classes and UPPER_CASE for constants. A steady style removes most case typos.