PHP FILTER_SANITIZE_MAGIC_QUOTESFilter


PHP Filter 参考手册Complete PHP Filter Reference

Definition and Usage

The FILTER_SANITIZE_MAGIC_QUOTES filter executes theaddslashes()function on strings.

This filter adds backslashes before predefined strings.

Predefinedcharactersare:

  • Single quote (')
  • Double quote (\")
  • Backslash (\)
  • NULL

FILTER_SANITIZE_MAGIC_QUOTES Information:

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

Example

<?php $var="Peter's here!"; var_dump(filter_var($var, FILTER_SANITIZE_MAGIC_QUOTES)); ?>

The output of the code is shown below:

string(14) "Peter\'s here!"
PHP Filter 参考手册Complete PHP Filter Reference Other Extensions