php – Expected type ‘object’. Found ‘string|false’.intelephense(1006) on json_encode()


Please find my code sample below where I take the POST input data and convert into JSON after which I check if the data has the required info or not. I’m using Visual Studio with PHP Intelephense. It provides the error mentioned “Expected type ‘object’. Found ‘string|false’.intelephense(1006)”. As I am new to PHP, can someone assist why this is an issue?

$data = json_encode(file_get_contents("php://input"));

if(
   !empty($data->symbol) &&
   !empty($data->trading_date) &&
   !empty($data->series))
{ // do something
}



Source link

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top