Please enable Javascript to view this site.
  • Coding

  • Technology

  • Japanese

  • Chinese

  • Miscellaneous

Case Sensitivity in PHP

July 14, 2010 | Tags: | Leave a comment

It surprised me to learn that class names in PHP are actually case insensitive. That means the following is legal:

class MyController {}
$obj = new mYcOnTrOlLeR;

User defined function names are also case insensitive, as well as certain keywords and constructs like echo. Variable names are case sensitive, so the madness ends there at least. This can be confusing to people coming from other languages like Java, Ruby, and C (and its variants) where everything is case sensitive.

To be safe, you should probably always keep your cases straight and strictly defined when working in PHP. But knowing this helps when reading through code and wondering how a new object can be created when there’s no class defined with an exact, case-sensitive match.

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.