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?

1
  • Same issue, did you solve the problem ? Commented Nov 4, 2024 at 14:15

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.