How to check if php://input is set?

后端 未结 4 2173
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 10:54

I need to check if php://input exists/isset. Does it work with php isset() ? What is the proper way to check it?

4条回答
  •  没有蜡笔的小新
    2021-02-19 11:29

    You can get the contents of php://input using file_get_contents and check the return value to see if it's actually set:

    $input = file_get_contents("php://input");
    if ($input) {    
        // set     
    }
    else {
       // not set
    }
    

提交回复
热议问题