When I get file content from javascript, decode it and get the value of object. It display trying to get property of non-project. However, the object variable is successfully pass to another php class. May I know why it cause this problem? I had try all the solution from stackoverflow but it not work and it also display the same error. The following is my code:
$chat_info = file_get_contents("php://input");
$chat_request = json_decode($chat_info);
$username = $chat_request->username;
$messageContent = $chat_request->messageContent;
$dateTime = $chat_request->date_time;
$channel = $chat_request->channel;
$event = $chat_request->event;
You can also do this:
$chat_info = file_get_contents("php://input");
$chat_request = json_decode($chat_info,true);
$username = $chat_request['username'];
$messageContent = $chat_request['messageContent'];
$dateTime = $chat_request['date_time'];
$channel = $chat_request['channel'];
$event = $chat_request['event'];
And after it if it show any error like undefined index
then the $chat_info
variable does not contain the value of a key that you want.
Probably one of the object which you use get from time to time NULL value. Check this out, i hope that is correct answer.