PHP从DOMDocument(loadXML)获取值
我正在使用web服务(curl)来验证一个值。尽管我无法在变量中存储(和比较)答案,但一切都很好。我使用的是一个PHP类PHP从DOMDocument(loadXML)获取值,php,xml,domdocument,Php,Xml,Domdocument,我正在使用web服务(curl)来验证一个值。尽管我无法在变量中存储(和比较)答案,但一切都很好。我使用的是一个PHP类(XY.PHP)。因此,我从AA发送请求。PHP,应该在那里得到答案打印($doc->firstChild->textContent)工作正常,但我无法存储答案。有什么想法吗?提前谢谢 AA.php require 'includes/XY.php'; ... $verify->VerifyIt(); if ($verify === "StatusCod
(XY.PHP)
。因此,我从AA
发送请求。PHP,应该在那里得到答案<代码>打印($doc->firstChild->textContent)工作正常,但我无法存储答案。有什么想法吗?提前谢谢
AA.php
require 'includes/XY.php';
...
$verify->VerifyIt();
if ($verify === "StatusCode:30") {
$text = "<p> okay</p>";
echo $text; }
XY.php
...
$doc = new DOMDocument();
$doc->loadXML($result);
print_r($doc->firstChild->textContent);
return $doc->firstChild->textContent;
AA.php
需要“includes/XY.php”;
...
$verify->VerifyIt();
如果($verify==“StatusCode:30”){
$text=“好的””;
echo$text;}
XY.php
...
$doc=新的DOMDocument();
$doc->loadXML($result);
打印($doc->firstChild->textContent);
返回$doc->firstChild->textContent;
$verify
是一个对象,它不能等于“StatusCode:30”;不知道这对print\r($doc->firstChild->textContent)应该如何工作,我得到了答案“StatusCode:30”。。。所以我想应该有可能找到答案。。。更好的办法是得到数字30。我相信你可能会遇到PHP的一个“神奇方法”\uuuuu tostring“神奇方法”做到了,但不是必需的……谢谢你的输入。解决方案:$var=print\u r($doc->firstChild->textContent,true);返回$var;