此代碼是工作前2天,但現在我得到一個錯誤:注:試圖獲得非對象的屬性在C: XAMPP htdocs中 ihelploginapi 上線的index.php 5
Trying to get property of non-object in C:\xampp\htdocs\ihelploginapi\index.php on line 4.
有人請幫助我。
<?php
$json = file_get_contents('php://input');
$obj = json_decode($json,TRUE);
$tag = $obj->{'tag'};
?>
你可以'var_dump($ obj)'在json_decode之後的行併發布結果嗎? – Scott
錯誤:解析錯誤:語法錯誤,意想不到 '$標籤'(T_VARIABLE)在C:\ XAMPP \ htdocs中\ ihelploginapi \的index.php上線.. –
代碼:<?PHP \t $ JSON =的file_get_contents('PHP: //輸入'); \t $ obj = json_decode($ json,TRUE); \t var_dump($ obj) \t $ tag = $ obj - > {'tag'}; \t if($ tag =''){ //獲得標籤 $ tag = $ obj - > {'tag'}; –