我需要检查是否php://input
存在/设置。它可以与 PHP 一起使用吗isset() https://php.net/isset?正确的检查方法是什么?
尝试用以下方法测试它file_get_contents() http://php.net/file-get-contents(供阅读)+empty() http://php.net/empty or 布尔转换 http://www.php.net/manual/en/language.types.type-juggling.php(供测试用):
<?php
$input = file_get_contents('php://input');
if ($input) {
// exists
} else {
// not exists
}
From php.net http://php.net/manual/en/wrappers.php.php:
Note: PHP 5.6 之前的版本,一个流打开了php://input
只能读一次;该流不支持查找操作。但是,根据 SAPI 实现,可能会打开另一个 php://input 流并重新开始读取。仅当请求正文数据已保存时才可能实现。通常,POST 请求属于这种情况,但其他请求方法(例如 PUT 或 PROPFIND)则不然。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)