如何在VSCODE中使用PHP 8.1语法?
我在C驱动器上的PC上安装了PHP 8.1.4,
但我在驱动器D中有XAMPP,这些drive D中有所有PHP文件,并且我在XAMPP中有PHP 8.1.2
我在VSCODE上安装了php intephense,并且我禁用PHP语言功能
但是,当我写php 8或8.1语法时,我的vscode显示错误
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须为PHP Intlephense扩展名为PHP版本指定。
2种方法:
8.1
。 alt =“”>
“ intelephense.environment.phpversion”:“ 8.1。*”
。nb:检查您是否拥有
php intlephense
的最后版本也非常重要!就是这样!
You have to specify your PHP version for the PHP intelephense extension.
2 ways to do that :
8.1.*
instead8.0.0
here :settings.json
with this :"intelephense.environment.phpVersion": "8.1.*"
.NB : check if you have the lastest version of
PHP Intelephense
it also very important!And that's it !
请注意,有两种设置 - 一个是用户的“主要”,对于 workspace 而言,工作空间具有更高的优先级。
进行设置
“ php.validate.executablepath”:“/usr/bin/php8.2”
/usr/bin/php8.2
带有您自己的PHP EXE的路径
php.exe
8.2.0
还请注意,如果您完全违反了PHP文件,则可能不会在首先显示某些错误 - 就像一个错误的命名参数 - 这并不是一个完全完全损坏的。语法错误,但如果没有以前的语法错误(例如“ php parse error ...”等...
另请参阅: https://code.visualstudio.com/docs/languages/php 有关VSCODE本身如何完成linting的更多信息。
Note there are 2 type of settings - one is the "main" for the User and secondary for the Workspace, the workspace has higher priority.
"php.validate.executablePath": "/usr/bin/php8.2"
/usr/bin/php8.2
with your own path to PHP exephp.exe
8.2.0
Also note that if you have broken PHP file completely, some errors may not be shown at first - like a wrong named argument - which is not exactly a syntax error but is validated later if there are not previous syntax errors (like "PHP Parse error..." etc...
Also see: https://code.visualstudio.com/docs/languages/php for more information on how VSCode itself does the linting.