PHP variable / function / class names using special characters

后端 未结 5 1528
忘了有多久
忘了有多久 2021-02-12 22:40

I understand that the underscore _ is an acceptable character for naming variables / functions / classes etc. However I was wondering if there are any other special

5条回答
  •  被撕碎了的回忆
    2021-02-12 22:56

    Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.

    http://www.php.net/manual/en/functions.user-defined.php

    Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

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

    See also, the Userland Naming Guide: http://www.php.net/manual/en/userlandnaming.php

提交回复
热议问题