Home > Back-end >  VSCode show error after use PHP Intelephense
VSCode show error after use PHP Intelephense

Time:02-14

I am trying to get post data from client, the code working fine until I switch to use PHP intelephense extension. It show that I have error "expected type 'object'. Found 'array'.intelephense(1006)"

my part of code that error is like ->

    if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($_POST)) {
    $_POST = json_decode(file_get_contents('php://input'));
}


$date = $_POST->date;
$branch = $_POST->idBranch;

The error part is at $_POST.

Is it error with the extension or is it my code that is not correct.

CodePudding user response:

You are using the $_POST in a wrong way. The Intelephense think that $_POST should always use like this:

$_POST['something']
  • Related