I am using PHP 5.6.12. I retrieve the results of a query from the database, and do as follows
$query = "SELECT `title`, `text`, `url`, `image`, `url_type` FROM `links`";
$result = $conn->query($query);
if(!$result) die($conn->error);
$rows = $result->num_rows;
for($j=0; $j<$rows; ++$j)
{
$result->data_seek($j);
$title=$result->fetch_assoc()['title'];
echo $title;
}
I have this code in a file abc.php
. I am developing using Eclipse.
In Eclipse, a syntax error is indicated beside the following line - it says:
syntax error, unexpected '['
title=$result->fetch_assoc()['title'];
The strange thing is that if I put the exact same code in a abc.html file and look at it in Eclipse, I don't see any error message in Eclipse.
However, when I look at the php page in a browser, it obtains the value for $title correctly. So why does Eclipse consider this an error? Is there somewhere in Eclipse where I can tell it what version of PHP to use for parsing ?