views:

205

answers:

1
function ag()
{
    echo '2';
}

Ag();
class test {
    function clMe()
    {
        echo 'hi';
    }
}

$instance = new test;
$instance->clme();

But that's the not case with variables,

what's the rationale in it?

+6  A: 

Yes, functions and methods names are not-case sensitive.

And yes, variables names are case-sensitive.

Not sure there's a reason for that -- except it's been this way for a long time, and, so, remains the case, for backward compatibility reasons.



As a reference, a couple of links / quotes to various pages of the manual :

For functions (quoting) :

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

And methods are not much more than functions in objects -- especially when we think about PHP 4 and backward-compatibility.


And, for variables (quoting) :

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

And object-properties and not much more than variables in objects -- same remark about PHP 4 and backward-compatibility.

Pascal MARTIN