如何在 VS Code 中为已删除的 mysql_* 函数添加智能感知 [英] How to add intellisense for removed mysql_* functions in VS Code

查看:24
本文介绍了如何在 VS Code 中为已删除的 mysql_* 函数添加智能感知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio Code 并在 PHP 系统上工作.在工作时,我所有的 mysql_* 调用都显示为错误(下划线),工具提示是:

<块引用>

未定义函数'mysql_query'

我正在使用旧的 PHP 版本,它仍然启用了这个功能,所以当我使用我的 Laragon 服务器并测试时,代码确实运行了.

在 PHP 扩展方面,我有 Intelephnse、PHP IntelliSense、PHP 扩展包、PHP 调试.

如何为这些已删除的 PHP 函数启用 VS Code 支持?

解决方案

首先,mysql_* 扩展在很久以前就已被弃用并从 PHP 中删除.所有项目都应该在过去 10 年中迁移,而那些还没有迁移的项目应该优先考虑这一点.

在谈到 VS Code 时,至少有两个 PHP 扩展支持智能感知和代码突出显示.如果您使用的是

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?

解决方案

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.

这篇关于如何在 VS Code 中为已删除的 mysql_* 函数添加智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆