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 characters which can be used. I tested out a few with no luck and have assumed for a long time that there are not, however I figured I would see if anyone else knows for certain. This would be mostly for aesthetic purposes, however I imagine a special character naming convention would be useful when working with other developers to define value types etc.
I understand that the underscore _ is an acceptable character for naming variables /
Share
If you check the
docs on variablesit says that:But basically people have agreed to only use
a-zA-Z0-9_and not the “fancy” names since they might break depending in the encoding one uses.So you can have a variable that is named
$aöäüÖÄbut if you save that with the wrong encoding you might run into trouble.The same goes for functions too btw.
So
will just work out (at least at first).
Also check out:
Exotic names for methods, constants, variables and fields - Bug or Feature?for some discussion on the subject.