Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is PHP function names case-sensitive or not? [closed]

Tags:

php

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.

like image 275
kpmDev Avatar asked Dec 03 '13 07:12

kpmDev


People also ask

Does function names are case-sensitive?

Note: Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.

Are PHP variable names case-sensitive or case-insensitive?

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 ).

Which of the following are not case-sensitive in PHP?

Summary. PHP is partially case-sensitive. PHP constructs, function names, class names are case-insensitive, whereas variables are case-sensitive.

Why is PHP partially 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.


2 Answers

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

like image 84
Anas Avatar answered Sep 22 '22 01:09

Anas


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

like image 21
Pankaj Pareek Avatar answered Sep 20 '22 01:09

Pankaj Pareek