for($j = 0; $j < $rows; ++$j)
{
$result->data_seek($j);
$row = $result->fetch_array(MYSQLI_NUM);
echo <<<_END
<pre>
Author: $row[0]
Title: $row[1]
Type: $row[2]
Year: $row[3]
ISBN: $row[4]
</pre>
_END;
}
There are two things I've encountered in using echo for block of texts and I'm a bit stumped in coming up with an explanation.
Any indentation of the
echoblock will cause the webpage to crash.If I change the
fetch_arraytype to eitherMYSQLI_ASSOC, orMYSQLI_BOTH, associative calls such as$row['author']cause the page to crash. Whereas using single-line calls toechowhile accessing$roware working fine.
_END;. And string interpolation in double quoted / heredoc context either needs literal"$row[key]"or complex"${row['key']}"syntax for quoted keys.