想問 使用PHP寫資料庫程式時遇到 Notice: Trying to access array offset on value of type bool in 該怎麼解?

第一次發文,排版不好請見諒。
如題,
想問 使用PHP寫資料庫程式時遇到 Notice: Trying to access array offset on value of type bool in 該怎麼解?

想問大大該怎麼解決!急~在線等!!謝謝
2020-04-29 1:48 發佈
type bool in <---------有寫錯嗎?


型別的種類

PHP 有8種基本的資料型態(Data Type)或簡稱型別(Type):
4種數值(scalar)的型別:

布林(boolean)
整數(integer)
浮點數(float或double)
字串(string)

2種複合(compound)的型別:

陣列(array)
物件(object)

https://emn178.pixnet.net/blog/post/78227901 <-----看一下

https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/215549/

https://blog.xuite.net/chingwei/blog/21108346-%E3%80%90%E7%A8%8B%E5%BC%8F%E3%80%91PHP+%3A+%E5%8F%96%E5%BE%97%E9%83%A8%E4%BB%BD%E9%99%A3%E5%88%97%E8%B3%87%E6%96%99
就是那變數是 bool 不是 array, 而你把它當 array 用.

有些 function (通常是 xxxx_fetch_row() 之類的函式) 的回傳是會是 array, 但是不成功的時候, 又會是 false (或是 null).
如果你把回傳的值直接當 array 使用, 如果那個真是 false 時, 就會有上面的訊息. (程式應該要先檢查回傳值是不是 array, 是的話才把它當 array 使用)
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?