How to add intellisense for removed mysql_* functions in VS Code

£可爱£侵袭症+ 提交于 2021-02-18 19:43:25

问题


I am using Visual Studio Code and working on a PHP system. While working, all my mysql_* calls are showing as an error (underlined) and the tooltip is:

Undefined function 'mysql_query'

I am working with old PHP version, which still has this functions enabled, so the code does actually run when I use my Laragon server and test.

In terms of PHP extensions I have Intelephnse, PHP IntelliSense, PHP Extension pack, PHP Debug.

How can I enable the VS Code support for these removed PHP functions?


回答1:


First of all, mysql_* extension has been deprecated and removed from PHP long time ago. All projects should have migrated in the past 10 years and those which still haven't done it should make this a priority.

When talking about VS Code there are at least two PHP extensions that support intellisense and code highlighting. If you are using Intelephense by Ben Mewburn you can still enable the old stubs in settings.

Follow the steps as described by Kapitan Oczywisty:

Set "intelephense.environment.phpVersion": "5.6.0" and add "mysql" to "intelephense.stubs"

This will ensure that you still get the intellisense support for these functions, but it will show you the deprecation warning and it will strike out the name of the function.



来源:https://stackoverflow.com/questions/59537146/how-to-add-intellisense-for-removed-mysql-functions-in-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!