Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 意外的简单simplexmlelement错误_Php_Laravel_Simplexml - Fatal编程技术网

Php 意外的简单simplexmlelement错误

Php 意外的简单simplexmlelement错误,php,laravel,simplexml,Php,Laravel,Simplexml,尝试使用PHP访问simplexmlelement时(下面第二个)。我使用下面的代码$candidate->result->recorddetail->FL[0],希望返回2972941000000380012,但到达(下面的第一个)。我只需要达到这个数据=2972941000000380012;多谢各位 编辑:当我访问FL阵列时,它不仅仅返回我想要的位置 SimpleXMLElement {#360 +"@attributes": array:1 [ "val" =>

尝试使用PHP访问simplexmlelement时(下面第二个)。我使用下面的代码
$candidate->result->recorddetail->FL[0]
,希望返回2972941000000380012,但到达(下面的第一个)。我只需要达到这个数据=2972941000000380012;多谢各位

编辑:当我访问FL阵列时,它不仅仅返回我想要的位置

    SimpleXMLElement {#360
  +"@attributes": array:1 [
    "val" => "Id"
  ]
  +0: "2972941000000380012"
}
当我返回字符串about时,接收到的不是目的地而是第二个代码块

    SimpleXMLElement {#357
  +"@attributes": array:1 [
    "uri" => "/crm/private/xml/Contacts/insertRecords"
  ]
  +"result": SimpleXMLElement {#352
    +"message": "Record(s) updated successfully"
    +"recorddetail": SimpleXMLElement {#355
      +"FL": array:5 [
        0 => "2972941000000380012"
        1 => "2018-01-17 14:39:17"
        2 => "2018-01-17 15:11:49"
        3 => SimpleXMLElement {#368
          +"@attributes": array:1 [
            "val" => "Created By"
          ]
        }
        4 => SimpleXMLElement {#369
          +"@attributes": array:1 [
            "val" => "Modified By"
          ]
        }
      ]
    }
  }
}
当您使用(例如)

这将指定SimpleXMLElement,而不是您真正想要的元素值。您可以通过将其转换为字符串来获取值,该字符串只返回元素内容

$x = (string)$candidate->result->recorddetail->FL[0];
请你回答这个问题,包括一个指向这个对象的实际XML的示例;SimpleXML的调试输出并不总是很有帮助,如果人们能够自己重现问题,就会更容易。还请包括您在该XML上运行的确切PHP。换言之,这是一个错误。
$x = (string)$candidate->result->recorddetail->FL[0];