wp_magic_quotes

函数
wp_magic_quotes ( No parameters )
Access
Private
定义位置
相关方法
add_magic_quoteswp_favicon_requestwp_get_siteswp_maybe_auto_updateis_main_query
引入
3.0.0
弃用
-

wp_magic_quotes: 这个函数为传入的数据添加斜线,以防止SQL注入攻击。然而,从WordPress 3.6开始,它已经被弃用了,不再需要了,因为WordPress现在使用准备好的语句提供数据库访问,可以防止SQL注入攻击。

在`$_GET`, `$_POST`, `$_COOKIE`和`$_SERVER`中加入魔力引号。

同时强制`$_REQUEST`为`$_GET + $_POST`。如果需要`$_SERVER`、`$_COOKIE`或`$_ENV`,直接使用这些超全局变量。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_magic_quotes() {
// Escape with wpdb.
$_GET = add_magic_quotes( $_GET );
$_POST = add_magic_quotes( $_POST );
$_COOKIE = add_magic_quotes( $_COOKIE );
$_SERVER = add_magic_quotes( $_SERVER );
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );
}
function wp_magic_quotes() { // Escape with wpdb. $_GET = add_magic_quotes( $_GET ); $_POST = add_magic_quotes( $_POST ); $_COOKIE = add_magic_quotes( $_COOKIE ); $_SERVER = add_magic_quotes( $_SERVER ); // Force REQUEST to be GET + POST. $_REQUEST = array_merge( $_GET, $_POST ); }
function wp_magic_quotes() {
	// Escape with wpdb.
	$_GET    = add_magic_quotes( $_GET );
	$_POST   = add_magic_quotes( $_POST );
	$_COOKIE = add_magic_quotes( $_COOKIE );
	$_SERVER = add_magic_quotes( $_SERVER );

	// Force REQUEST to be GET + POST.
	$_REQUEST = array_merge( $_GET, $_POST );
}

常见问题

FAQs
查看更多 >