问题
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