返回介绍

stripslashes_deep()

发布于 2017-09-11 10:29:45 字数 3546 浏览 1121 评论 0 收藏 0

stripslashes_deep( mixed $value )

Navigates through an array, object, or scalar, and removes slashes from the values.


description


参数

$value

(mixed) (Required) The value to be stripped.


返回值

(mixed) Stripped value.


源代码

File: wp-includes/formatting.php

function stripslashes_deep( $value ) {
	return map_deep( $value, 'stripslashes_from_strings_only' );
}

更新日志

Versiondescription
2.0.0Introduced.

相关函数

Uses

  • wp-includes/formatting.php: map_deep()

Used By

  • wp-includes/rest-api/class-wp-rest-request.php: WP_REST_Request::parse_body_params()
  • wp-admin/includes/ajax-actions.php: wp_ajax_send_attachment_to_editor()
  • wp-includes/formatting.php: wp_unslash()
  • wp-includes/formatting.php: wp_parse_str()
  • wp-includes/load.php: wp_magic_quotes()
  • wp-includes/class-wp-widget.php: WP_Widget::update_callback()
  • Show 1 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note Contributed by Codex

    Good Coding Practice
    WordPress adds slashes to $_POST/$_GET/$_REQUEST/$_COOKIE regardless of what get_magic_quotes_gpc() returns. So in the context of WordPress, stripslashes() or stipslashes_deep() should always be used when using those variables.

    Example:

    
    $my_post = stripslashes_deep($_POST);
    $my_value = $my_post['value'];
    

    Or:

    
    $my_value = stripslashes($_POST['value']);
    
  2. Basic Example
    You may want this function when developing your own PHP application intended to run within the WordPress environment. Specifically, your program needs to strip slashes when data arrives via $_POST, $_GET, $_COOKIE, and $_REQUEST arrays.

    An example would be a “Contact Me” page and the ancillary program that sanitizes the user-supplied text. Such user inputs typically travel from an HTML to your program by way of the $_POST array. stripslashes_deep(), in that case, could be used thus (caution, see notes below):

    
    $_POST = stripslashes_deep( $_POST );
    

    The stripslashes_deep() function is recursive and will walk through the $_POST array even when some of the elements are themselves an array.

    Please note: WordPress Core and most plugins will still be expecting slashes, and the above code will confuse and break them. If you must unslash, consider only doing it to your own data which isn’t used by others:

    
    $your_own_data = stripslashes_deep( $_POST['your_own_data'] );
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文