4

I noticed that Visual Studio Code is not showing an error about undefined variables.

For example:

<?php

   if ($test > 2) {
       echo 'hi';
   }

?>

If I run the code above, I would expect an error for undefined variable $test, but it’s not showing any errors under PROBLEMS: enter image description here

I only get a warning under TERMINAL.

Is there any way to make Visual Studio Code show an error for undefined variables or is it not possible?

Fastnlight
  • 922
  • 2
  • 5
  • 16
celalk38
  • 81
  • 8

1 Answers1

0

I was dealing with the same issue. At least with PHP Intelephense installed it turns out that you get don't get errors in the main body but you do get them inside a function body.

enter image description here

Rens
  • 489
  • 5
  • 11