I was digging through some code, and I found some calls to mySQL_fetch_array
. Is PHP case sensitive about function names? I recall reading this somewhere but can't seem to find any reference to it.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Keeping track of variable instances
- Can php detect if javascript is on or not?
I am quoting from this:
So, its looks like user-defined functions are not case-sensitive, there was a vote for making functions/objects under PHP5 case-sensitive.
And method names also case-insensitive. eg:-
output:
No.
PHP functions are not case sensitive.
In PHP variables are case sensitive but functions have no issue like this.You can use following statements for displaying output, all will show the same result.
On the other hand, if you will change the case sensitivity of variables then it will show the error.
Example:
Output:
In conclusion of everyone's response. Even though PHP does not require character case consistency in all instances even till now in PHP5.
Best practice will be
You never know maybe one day the vote get through and you will save the whole nightmare of changing cases in your applications made couple of years ago that require update in PHP.
Hope it helps in anyway.
TL;DR: class names are case-insensitive, but use always the same case as in the declaration (same as with functions). Also, instantiating classes with different case as they were defined may cause problems with autoloaders.
Also, class names are case-insensitive:
This outputs:
Problem is using autoloaders and case-sensitive file-systems (like ext2/3/4), in that you must call the class name with the same case the file containing the class is named (not how the class name is actually cased), or use
strtolower
:The class file:
The autoloader function (
__autoload
or a function to register withspl_autoload_register
)Now with this code:
You may made this work (ie. having effectively case insensitive class names using an autoloader) if you added a call to
strtolower()
in the autoloader code, but as with functions, is just better to reference a class in the same way as it is declared, have the filename with the same case as the class name, use autoloaders, and forget usingstrtolower
and the likes.