According to common sense, most languages are case-sensitive. For example, variables ab and AB are different, and functions cd and CD are also different, but PHP is a bit special.
First of all, variables and constants in php are case-sensitive.
<?php $a = 'a'; $A = 'A'; echo $a; echo $A; ?>
Two variables are printed here. If they are not distinguished, the later variables should overwrite the previous ones. Let’s look at the definition of constants:
<?php define('a', 'a'); define('A', 'A'); echo a; echo A; ?>
However, class names and method names in , and even some keywords are not case-sensitive .
<?php class person { function say() { echo 'hello'; } } $p = new Person(); $p->SAY(); ?>
This way of writing will not report an error, magical php, this will bring a lot of convenience, for example, under certain logic, no longer The first letter of the class name needs to be processed, but again, we should develop good code writing habits and not abuse this convenience, right? !
Related recommendations:
HTML tags are not case-sensitive
Summary of whether html css js php is case-sensitive
Small details: case distinction in css
The above is the detailed content of Detailed explanation on whether php is case sensitive. For more information, please follow other related articles on the PHP Chinese website!