10
Some time ago, by an accident at the time of a debug I realized that PHP makes no difference between upper and lower case when calling a function.
Example:
print_r($teste);
print_R($teste);
Print_R($teste);
Also the same thing occurs for class methods:
$fileIterator = new FileSystemIterator(__DIR__);
$fileIterator->current();
$fileIterator->Current();
foreach ($fileIterator as $file) {
echo $file->getRealPath();
echo $file->getRealpath();
echo $file->GETREALPATH();
}
To find out what is the "original" name of the method getRealPath
, I used the get_class_methods
in FileSystemIterator
. And the result was:
[32] => getRealPath
And in the PHP Handbook it is also like this.
The question is, even if it is case-insensitive, on account of having a "default name" set to the methods and functions, I must worry about writing them exactly as they are in the manual?
Well, from my memory, I know FileSystemIterator
has a method called getRealPath
, but sometimes I forget how to write (if it is getRealPath
or getRealpath
), and by working, I leave it the way it really is.
I should be concerned with this "writing" at the time of the method call?
Case-insensitive and case-sensitive sections are inverted, not?
– Rodrigo Rigotti
Yeah, I reversed it, I’ll fix it :)
– Maniero
I thought about wanting to write in the right way for another reason: "PHP will change everything in future versions!"
– Wallace Maxters
It is a concern, but I do not think it valid. If the language does this becomes another language.
– Maniero
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
– Wallace Maxters
It is not worth mentioning that
TRUE
andFALSE
are case-insensitive, despite being constant (are constructs of language, yes; as you noted, the distinction makes no sense...)?– user25930