php输入验证检查和simplexml_load_string

时间:2014-02-05 20:33:10

标签: php simplexml

if(isset(file_get_contents("php://input"))) {
        $credentialsXML = simplexml_load_string(file_get_contents("php://input"));
}

我们如何检查php://输入是否存在然后继续解析,因为有些情况下php://输入为空,我根本不需要调用simplexml_load_string

1 个答案:

答案 0 :(得分:1)

你为什么不这样做:

$input = file_get_contents('php://input');
if (!empty($input)) {
    $credentialsXML = simplexml_load_string($input);
}