简体   繁体   中英

Visual Studio Code is not showing an error for undefined variables PHP

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: 在此处输入图像描述

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?

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM