EducationIs PHP Case sensitive? What are sensitive words in PHP?

Is PHP Case sensitive? What are sensitive words in PHP?

Hypertext PreProcessor acronym PHP which was earlier known as the Personal Home Page (PHP) is widely used and well known server-side scripting language which is an alternative to the server-side scripting languages such as — Active Server Pages (ASP) and Java Server Pages (JSP).

PHP is used by many known social-networking websites which include Facebook and the blogging websites like WordPress. You must have raised the same question to your teachers, whether the PHP is a case sensitive programming language or not. If so, then what are the case sensitive words in PHP?

In this article, I assist you all in clearing your doubt on — whether the PHP is a case sensitive language or not. Indeed, the PHP is not a case sensitive language, but in other hands, it is neither case insensitive language since it is comprised of both, i.e. — PHP is a case sensitive as well as case insensitive language. It might be a bit confusing for most of you. So, let’s make it more transparent with an example.

Case Sensitive Words in PHP

In PHP constants, variables, array keysclass constants and class properties is the case sensitive words and functions, whether it is a user-defined or PHP system-defined (i.e. — inbuilt).

Constants are Case sensitive

In PHP, constants are similar to variables with two exceptions, i.e. — once it is defined, it cannot be changed or undefined.

For example to define a constant in PHP named “CITY”, we’ll use following PHP snippet

define("CITY","New Delhi"); //declaration and definition
echo CITY; // prints the value of CITY i.e. "New Delhi"

Here in this example, constant CITY is case-sensitive, which means calling it as city or City will be treated as a different variable.

Variables are Case sensitive

In PHP variables starts with a dollar sign ($) and are known as the containers which are used to store information. There are mainly three types of variables in PHP, which include :

  1. Integer
  2. String
  3. Boolean

Similarly to the constants in PHP, the variables are also case sensitive. Which means it should be used the same as it is declared.

For example —

$COUNTRY="India" //string
$Country=91; // integer 
$country=True; // Boolean 
echo $COUNTRY; // Output: India 
echo $Country; // Output: 91
echo $country; // Output: True

In the above example, the country variable is used with the three different data-types where each variable is used to store different value but have the same spelling.

Array keys are Case sensitive

Array_keys() is a special type of function used to access and manipulate arrays in PHP. It supports multi-dimensional and straightforward arrays in PHP.

Same as variables and constants array_keys() are also case-sensitive.  For example —

$address=array("Country"=>"India","State"=>"New Delhi","CountryCode"=>"91");



In the above example, $address and $ADDRESS will be treated as two different arrays.

Class Constants are Case sensitive

As like in constants which let the user define a variable in the programme which cannot be changed or re-define, the class constants do the same function as constant in PHP.

Here in case of a constant class in PHP, the entire class defined as the constant which remain the same and unchanged as the user predefines it. For example —

class TestClass
    const UserName = "Isrg Rajan";
    const UserCity= "New Delhi";
echo "Name of the user: ". TestClass::UserName;
echo "City of the user: ". TestClass::UserCity;

Here in case of constant class, class name and the object names are case sensitive.

Class Properties are Case sensitive

In PHP, class properties are case sensitive and are also known as attributes and fields. The class properties are defined with one of the keywords from — public, private and protected followed by the standard variable deceleration procedure.

class UserInfo {
private $username="[email protected]";
private $userpwd="123456";

class userInfo {
private $Username="[email protected]";
private $Userpwd="123456";


Here in the above example, Classes, UserInfo and userInfo will be treated two different classes and thus its properties.

Case Insensitive Words in PHP

Case Insensitive also referred to as the “non-sensitive” and “not sensitive” in most of the programming languages. In computer programming case insensitive words whether it is the lower-case or upper case are interpreted and treated as the same words.

In PHP functions, class constructors and class methods are cases insensitive where constructs and keywords like if, else, null, echo and foreach etc. are case insensitive.

Isrg Team
Isrg Team
Isrg Team is a member of Digital Pradesh News Networks, a collective of journalists, reporters, writers, editors, lawyers, advocates, professors, and scholars affiliated with the Digital Pradesh News Network.

Latest Updates