1

(I don't think this is a duplicate question-- I found many questions close to this but could not find anything that asks exactly this.)

I have a site where users enter a member name. The entire site (PHP, database) is UTF-8, and I want to allow members to enter UTF-8 characters (emojis, etc) in other places. But for the member name, I need to limit the content to basic letters and a few punctuation characters.

What's the right way in PHP to filter a UTF-8 input string (from a ) and filter out all characters except A-Z, a-z, 0-9, "_" and "-"?

Eric
  • 5,104
  • 10
  • 41
  • 70

0 Answers0