Advertisement
AlexWebDevelop

URL and HTML sanitization

Feb 18th, 2021
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. /* Parameter URL values */
  2. $name = 'param1';
  3. $surname = 'param2';
  4.  
  5. /* Sanitized URL parameter values */
  6. $nameSanitized = urlencode($name);
  7. $surnameSanitized = urlencode($surname);
  8.  
  9. /* URL string */
  10. $url = 'http://yoursite.com?name=' . $nameSanitized . '&surname=' . $surnameSanitized;
  11.  
  12. /* URL string sanitized for HTML */
  13. $urlHTML = htmlentities($url, ENT_QUOTES | ENT_HTML5, 'UTF-8');
  14.  
  15. echo '<a href="' . $urlHTML . '">';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement