WordPress开发者和主题制作者的搜索引擎



wp_slash ›

Since3.6.0
已弃用n/a
wp_slash ( $value )
参数:
  • (string|array) $value String or array of strings to slash.
    Required: Yes
返回:
  • (string|array) Slashed $value
定义在:
文档:

Add slashes to a string or array of strings.

This should be used when preparing data for core API that expects slashed data. This should not be used to escape data going directly into an SQL query.



Related Functions: wp_unslash, wp_hash, wp_styles, wp_rss, wp_salt

源码

function wp_slash( $value ) {
	if ( is_array( $value ) ) {
		foreach ( $value as $k => $v ) {
			if ( is_array( $v ) ) {
				$value[ $k ] = wp_slash( $v );
			} else {
				$value[ $k ] = addslashes( $v );
			}
		}
	} else {
		$value = addslashes( $value );
	}

	return $value;
}