2017-09-02 45 views
1

使用firebase php,我得到一個簡單的$firebase->set($data,$location)函數中的錯誤。Firebase php無效字符值錯誤

未捕獲異常'Kreait \ Firebase \ Exception \ FirebaseException'與 消息'The location key「rural foothills m.d.」包含以下無效字符:$#[]'

有沒有一種方法來清理值以避免錯誤?

謝謝!

回答

0

有時候你會看到一個錯誤,說「無效的數據,無法解析JSON對象,數組或值,也許你的密鑰名稱中使用了無效字符

當您嘗試發送到Firebase的字段包含無效字符時,會發生此錯誤。 Firebase禁止包含以下密鑰名稱:

. (period) 
$ (dollar sign) 
[ (left square bracket) 
] (right square bracket) 
# (hash or pound sign) 
/(forward slash) 

要解決此錯誤,您需要手動爲密鑰指定名稱。

參考:Common Problems with Firebase