Are PHP keywords case-sensitive?

后端 未结 3 1146
挽巷
挽巷 2020-12-06 02:30

For example, is the following program meaningful, and if so what should it print?



        
相关标签:
3条回答
  • 2020-12-06 02:57

    No. Keywords are case-insensitive. Lerdorf et al., Programming PHP, page 17:

    The names of user-defined classes and functions, as well as built-in constructs and keywords such as echo, while, class, etc., are case-insensitive. Thus, these three lines are equivalent:

    echo("hello, world");
    ECHO("hello, world");
    EcHo("hello, world");
    
    0 讨论(0)
  • 2020-12-06 03:04
    1. No, Keywords are not case-sensitive.
    2. Class name & function name also not case-sensitive.
    0 讨论(0)
  • 2020-12-06 03:12

    Case sensitive (both user defined and PHP defined)

    • variables
    • constants
    • array keys
    • class properties
    • class constants

    Case insensitive (both user defined and PHP defined)

    • functions
    • class constructors
    • class methods
    • keywords and constructs (if, else, null, foreach, echo etc.)
    0 讨论(0)
提交回复
热议问题