I am from Java background. In Java, every method has case-sensitive while calling. But in PHP, I didn't see the case-sensitive function name while calling the functions.
class Sample {
...
...
function sampleFunction() {
....
....
}
}
$obj = new Sample();
$obj->sampleFunction(); /* Proper call with function name */
$obj->samplefunction(); /* It should show undefined function error but it also calls sampleFunction() */
Can anyone clear my doubt why this is also called even non-case sensitive function name. And please give me how to restrict in PHP?
Thanks in advance.
Note: Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. Note: For our purposes here, a letter is a-z, A-Z, and the bytes from 128 through 255 ( 0x80-0xff ).
Summary. PHP is partially case-sensitive. PHP constructs, function names, class names are case-insensitive, whereas variables are case-sensitive.
PHP is a unique programming language in terms of case sensitivity. In PHP, variables and constants are case sensitive, while functions are not case sensitive. PHP classes are a mix between variables and functions, so they are partially case-sensitive.
They are case insensitive, see this:
Note: Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.
http://www.php.net/manual/en/functions.user-defined.php
Functions are not case sensitive, Variables are case sensitive.
you can read more info from manual :
http://fr.php.net/manual/en/functions.user-defined.php
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