Recently I was working with results from an SQL query call on a mysqli object. I wrote this line of code:
$record = ($result->fetch_object())->acc_id;
and i got Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)
for that line.
Once i changed the code to this:
$record = $result->fetch_object()->acc_id;
it worked as intended.
Why did the parenthesis induce a parse error? I know that in C# the former code would work regardless of them (accounting for the change in syntax)?