Search code examples
phpcase-insensitive

Php: are magic functions like magic constants: case insensitive?


On the official manual, you can read that magic constants are case-insensitive:

http://php.net/manual/en/language.constants.predefined.php

I've tested on __tostring() and __toString() and it's the same = case-insensitive.

There's no documentation about it.

Do you know if all magic functions are like magic constants = case insensitive?


Solution

  • 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/functions.user-defined.php

    This has to do how function names are stored in PHP internally. And for some languages (like Turkish) this can even lead to problems:


    Variable names on the other hand are case-sensitive:

    The variable name is case-sensitive.

    http://php.net/manual/language.variables.basics.php