deslash

函数
deslash ( $content )
参数
  • (string) $content The content to modify.
    Required:
返回值
  • (string) The de-slashed content.
定义位置
相关方法
wp_slashwp_unslashaddslashes_gpcdbdeltabackslashit
引入
1.5.0
弃用
-

deslash是一个WordPress的函数,可以从一个字符串或一个字符串数组中删除斜线: 这个函数在处理从表单中提交的数据时非常有用,在这些数据中可能已经添加了斜线以防止某些字符破坏表单。

内容的过滤器,删除不必要的斜线。

function deslash( $content ) {
	// Note: \ inside a regex denotes a single backslash.

	/*
	 * Replace one or more backslashes followed by a single quote with
	 * a single quote.
	 */
	$content = preg_replace( "/\+'/", "'", $content );

	/*
	 * Replace one or more backslashes followed by a double quote with
	 * a double quote.
	 */
	$content = preg_replace( '/\+"/', '"', $content );

	// Replace one or more backslashes with one backslash.
	$content = preg_replace( '/\+/', '\', $content );

	return $content;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: