phphtmlarrayshtml-content-extractionhtml-components

php warning: illegal string offset ‘name’ in GetUrl.php on line 855


I got error from my Apache log:

php warning: illegal string offset ‘name’ in GetUrl.php on line 855

Here is the page code:

function find_header_by_name($header_name) {
    if (!$this - > headers_received) {
        $this - > GetUri - > errors[] = “Error looking up header: headers have not been received yet”;
        return false;
    }

    $Response = false;
    foreach($this - > headers as $header) {
        if (!strcasecmp($header[‘name’], $header_name))
            $Response[] = $header[‘value’];
    }
    return $Response;
}

The error code is this part:

foreach($this - > headers as $header) {
    if (!strcasecmp($header[‘name’], $header_name))
        $Response[] = $header[‘value’];
}
return $Response;

How to fix it? I can’t find it, please help


Solution

  • You can

    print_r($this->headers);

    or

    var_dump($this->headers);

    to check it has results or not.

    if there is not have any results,there will throw the error that you seen.

    p.s:I'm a Chinese,this is my first answer in stackoverflow,I hope you can remember what i said ;)