PHP & Case Sensitivity 

Why is PHP partially case senstive?

I can only speculate that this stems from very early versions, probably PHP/FI 2.0. The manual explicitely states:

Keep in mind that PHP/FI function names are not case sensitive.

Most user input, such as GET and POST parameters, has always been registered as global variables, back then. Treating these as case insensitive would likely have caused issues, and supposedly therefore all variables have been treated as being case sensitive.

From what I can tell these have been the only kinds of identifiers in PHP/FI 2.0. All others have been introduced later, apparently mimicking the case-insensitive function names.

Constants, which are special, have only been introduced as of PHP 4 (the PHP 3 manual mentions “constants”, but these are nowadays referred to as “literals”). For some mysterious reason (maybe no consensus could be found), it had been decided to allow constant identifiers to be define()d either case sensitive or insensitive on the developers discression. Interestingly, while define() defaults to case sensitive constants, the respective C counterparts (REGISTER_*_CONSTANT) default to case insensitive.

Leave a Comment