Case Sensitivity in PHP
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.
Recent Comments
Japanese
Chinese
Miscellaneous
Tags
Archives
Browse the archives:
No comments yet.
No trackbacks yet.