0
    $response = curl_exec($ch);
    curl_close($ch);
    //Split the HEADERS and BODY 
    list($h, $EALOGIN) = explode("\r\n\r\n", $response, 2);
    $r = explode("\r\n", $h);

    //EASW Key
    $s = explode(":", $r[7]);
    $t = explode(";", $s[1]);
    $EASW_KEY = $t[0]; 
    //Session Key
    $m = explode(":", $r[8]);
    $n = explode(";", $m[1]);
    $EASF_SESS = $n[0];
    //nuc
    $a = explode("<nucleusId>", $EALOGIN);
    $b = explode("</nucleusId>", $a[1]);
    $NUC = $b[0];

离线是指“$a”行。我不明白这个错误。我该如何解决?

4

3 回答 3

1

该问题可能是由于$a[1]未设置。

在此语句中可能找不到分隔符:

$a = explode("<nucleusId>", $EALOGIN);

尝试使用调试语句(var_dump()'s 等)并试验代码以找出问题的根源。

于 2012-11-30T21:03:35.763 回答
0

用 preg_match 试试

$pattern = "/<nucleusId>(.*)<\/nucleusId>/";
preg_match($pattern, $string, $matches);
$NUC = $matches[1];
于 2012-11-30T21:26:06.857 回答
0

“未定义的偏移量”意味着某些数组没有具有特定键的元素。它可能是$a数组。

我建议像这样调试该代码:

$response = curl_exec($ch);
curl_close($ch);
//Split the HEADERS and BODY 
list($h, $EALOGIN) = explode("\r\n\r\n", $response, 2);
$r = explode("\r\n", $h);

//EASW Key
$s = explode(":", $r[7]);
$t = explode(";", $s[1]);
$EASW_KEY = $t[0]; 
//Session Key
$m = explode(":", $r[8]);
$n = explode(";", $m[1]);
$EASF_SESS = $n[0];
//nuc
$a = explode("<nucleusId>", $EALOGIN);

// debug start
echo "<pre>";
print_r($a);
echo "</pre>";
// debug end

$b = explode("</nucleusId>", $a[1]);
$NUC = $b[0];
于 2012-11-30T21:23:10.983 回答