Is PHP Case-Sensitive

Is PHP a Case-Sensitive Language? A Simple Explanation

Is PHP Case-Sensitive?

Short answer: variables are case-sensitive in PHP, but keywords, functions, and class names are not.

When I first started learning PHP, I kept asking: “Does PHP care about uppercase and lowercase letters?” The truth is simple but important. PHP is partially case-sensitive. Here’s what that means in practice, with easy examples.

Variables are Case-Sensitive

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

$Name = "John";
echo $name; // Notice the lowercase 'n' here
// This won't print "John" because $Name !== $name

Tip: pick one style (like $userName or $username) and stick to it to avoid bugs.

Keywords, Functions, and Class Names Are Not Case-Sensitive

You can write them in any case, though most developers prefer lowercase for consistency.

echo "Hello World!";
ECHO "Hello Again!"; // Works the same as echo
function greet() {
  echo "Hi there!";
}

GREET(); // Still works

Why This Matters

  • Prevents hard-to-spot bugs from mixed casing.
  • Makes your code consistent and easier to read.
  • Speeds up debugging when something doesn’t print as expected.

Quick Summary

  • Variables: case-sensitive
  • Keywords (like echo): case-insensitive
  • Function & class names: case-insensitive in calls

Keep this rule in mind and your PHP journey will be much smoother.

http://azadchouhan.online

Leave a Comment

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

*
*