PHP Arrays - Trying to get property of non-object

前端 未结 3 764
逝去的感伤
逝去的感伤 2021-02-09 13:31

I am still new to PHP so please bear with me.

So I am getting this error: Notice: Trying to get property of non-object on this line:

echo (
            \         


        
3条回答
  •  盖世英雄少女心
    2021-02-09 13:44

    I was thinking - how would I convert an array into an object? Maybe that would be my solution.

    That indeed would be one solution.

    $row = (object) $row;
    

    Another would be to use the right syntax for the data-type in question, in this case an array.

    Instead of

    $row->last_name
    

    You should use

    $row['last_name']
    

提交回复
热议问题