DEV Community

Discussion on: Cross-site Scripting (XSS) and ways to prevent it in PHP applications

Collapse
 
paul_dudink profile image
Paul Dudink

I believe it is recommended to use filter_var nowadays. Apart from XSS type of filtering it's also great to check for example an emailaddress, instead of using a regex. See all types of filters.

Collapse
 
giulio profile image
Giulio "Joshi"

I do agree, also using filter_input() and filter_input_array() should be preferred to using superglobals.

<?php
$customerEmail = filter_input( INPUT_GET, 'user_email', FILTER_SANITIZE_EMAIL );
Enter fullscreen mode Exit fullscreen mode
Collapse
 
qbentil profile image
Bentil Shadrack

Thanks for the input

Collapse
 
qbentil profile image
Bentil Shadrack

That's imperative to do.
Thanks for adding👏