Guest User

Untitled

a guest
Aug 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. php - Clean user input using preg_replace_callback and ord()?
  2. function replaceHTML ($match) {
  3. return "&#" . ord ($match[0]) . ";";
  4. }
  5.  
  6. $clean = preg_replace_callback ( "/[^ a-zA-Z0-9]/", "replaceHTML", $userInput );
  7.  
  8. $clean = preg_replace_callback('/[^a-z0-9s]/i', 'htmlentities', $userInput);
Add Comment
Please, Sign In to add comment