Functions and methods in PHP are case-insensitive as illustrated in the following example.
function ag() { echo '2'; } Ag(); class test { function clMe() { echo 'hi'; } } $instance = new test; $instance->clme();
But that's the not case with variables. What's the rationale?
In PHP, class names as well as function/method names are case-insensitive, but it is considered good practice to them functions as they appear in their declaration.
Summary. PHP is partially case-sensitive. PHP constructs, function names, class names are case-insensitive, whereas variables are case-sensitive.
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.
In PHP, variable and constant names are case sensitive, while function names are not.
Let me quote from Interview – PHP’s Creator, Rasmus Lerdorf
The first version of PHP was a simple set of tools that I put together for my Website and for a couple of projects. One tool did some fancy hit logging to an mSQL database, another acted as a form data interpreter. I ended up with about 30 different little CGI programs written in C before I got sick of it, and combined all of them into a single C library. I then wrote a very simple parser that would pick tags out of HTML files and replace them with the output of the corresponding functions in the C library.
The simple parser slowly grew to include conditional tags, then loop tags, functions, etc. At no point did I think I was writing a scripting language. I was simply adding a little bit of functionality to the macro replacement parser. I was still writing all my real business logic in C.
I have read somewhere that since all the functions introduced essentially felt like tags in an HTML document and since HTML tags were case insensitive, he chose function names in PHP to be case insensitive. Later on this feature remained on in the language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With