[英]Yii2: How to stop yii2 from escaping $_POST variables?
Yii2 escapes all $_POST
variables by adding additional slashes. Yii2通过添加其他斜杠来转义所有
$_POST
变量。 How to stop that? 如何停止呢? (
Magic quotes
are disabled in PHP. Additional slashes are added by yii2
, not by PHP
) (在PHP中禁用了
Magic quotes
。其他斜杠由yii2
添加,而不由PHP
)
My bad. 我的错。 Yii doesn't change $_POST.
Yii不会更改$ _POST。 And magic quotes are disabled.
并且禁用魔术引号。
The reason $_POST variables are escaped is because in my yii app I'm loading Wordpress wp-load.php and it is Wordpress who changed $_POST . $ _POST变量被逸出的原因是因为在我的yii应用程序中,我正在加载Wordpress wp-load.php, 而Wordpress更改了$ _POST 。
It is done in wp-settings.php by calling wp_magic_quotes() function. 通过调用wp_magic_quotes()函数在wp-settings.php中完成此操作。 To avoid this I remember contents of $_GET, $_POST, $_REQUEST, $_COOKIE and $_SERVER, then load wp-load.php, cache all data I need from WP and revert back.
为了避免这种情况,我记得$ _GET,$ _ POST,$ _ REQUEST,$ _ COOKIE和$ _SERVER的内容,然后加载wp-load.php,从WP缓存我需要的所有数据并还原。
Thanks for your comments! 感谢您的意见!
Yii2 doesn't change $_POST
in any way because it's considered a bad practice. Yii2不会以任何方式更改
$_POST
,因为这被认为是不好的做法。 The problem is most likely with magic quotes, check it once again more accurately. 问题很可能是用魔术引号引起的,请再次更准确地检查它。
Related questions: 相关问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.