Pergunta

My script is working really fine on my xampp. Now I tried to upload it on the server, but it spat directly a

Parse error: syntax error, unexpected '['

in my face. :(

The line which its mocking about is this one:

    $item = $xml->xpath($path)[0];

And I have no idea what is wrong. I tried to look on the php 5.3 changelog but did not found anything about it. (Because I have 5.3 on the server, and on xampp its an olderversion)

The whole code block looks like this:

$path = '//item[@id="'.$id.'"]';
if ($xml->xpath($path)) {
    $item = $xml->xpath($path)[0];
} else {
    die('<p class="error">Script Error: Code 101 - Please contact administrator</p>');
}

I am thankful for any help, I cannot seach [ with google and have no idea where it could come from, since on xampp its working fine

Foi útil?

Solução

Try this $item = $xml->xpath($path);
$item = $item[0];

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top