FILTER_SANITIZE_MAGIC_QUOTES constant in PHP

PHPProgrammingServer Side Programming

The FILTER_SANITIZE_MAGIC_QUOTES constant performs the addslashes() function to a string. It adds backslashes in front of predefined characters i.e. single quote ('), double quote ("), backslash (\), NULL.

Return

The FILTER_SANITIZE_MAGIC_QUOTES constant does not return anything.

Example

 Live Demo

<?php
   $var = "Here's the string!!";
   var_dump(filter_var($var, FILTER_SANITIZE_MAGIC_QUOTES));
?>

Output

The following is the output.

string(20) "Here\'s the string!!"
raja
Published on 04-Dec-2018 07:54:33
Advertisements