Understanding PHP function names.Can I also use "asterisk*" or "escape\"?

Asked 1 years ago, Updated 1 years ago, 487 views

Can I also use "asterisk*" or "escape\" for PHP function names?
For example, is a function name like fetch_*_id OK?

The function name follows the same rules as the other labels in PHP.Valid forms of function names begin with letters or underscores followed by any number of letters, numbers, or underscores.The regular expression is ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$.

List of reserved words

php

2023-02-02 23:35

1 Answers

I think it would be faster to actually try it myself...

In UNIXODE, * is U+002A and \ is U+005C in UTF-8 notation, which means \x2A or \x5C, but does not include the regular expression [a-zA_Z\x80].

The full-width asterisk * is \xEF\xBC\x8A in the U+FF0A UTF-8 notation, which is included in the previous regular expression, so OK

<?php function f*o() {echo sha1("abc");}
f*o()?>

was successful.

Not sure if it matches the user-level naming guide, but it's a good idea not to use this kind of (so-called) full-width characters as they cause religious wars.


2023-02-03 09:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.