PHP FILTER_SANITIZE_MAGIC_QUOTES Filter

Definition and Usage

The FILTER_SANITIZE_MAGIC_QUOTES filter performs the addslashes() function on strings.

This filter sets a backslash before the predefined strings.

The predefined characters are:

  • single quote (')
  • double quote ("}
  • backslash (\)
  • NULL

FILTER_SANITIZE_MAGIC_QUOTES Information:

  • Name: "number_float"
  • ID-number: 521

Example

<?php

var_dump(filter_var($var, FILTER_SANITIZE_MAGIC_QUOTES));
?>

Output:

string(14) "Peter\'s here!"