cannot be resolved to a type" for default php classes like DateTime, 异常等-6ren"> cannot be resolved to a type" for default php classes like DateTime, 异常等-在最近的一些 Eclipse 更新和工作区更改之后,我发现在 PDT 中验证我的 PHP 代码时存在一些问题。在为我的项目重新添加所有外部库后,每个外部类都是可解析的,但对于“DateTime”或“E-6ren">
gpt4 book ai didi

php - Eclipse PDT : " cannot be resolved to a type" for default php classes like DateTime, 异常等

转载 作者:可可西里 更新时间:2023-11-01 13:36:11 27 4
gpt4 key购买 nike

在最近的一些 Eclipse 更新和工作区更改之后,我发现在 PDT 中验证我的 PHP 代码时存在一些问题。在为我的项目重新添加所有外部库后,每个外部类都是可解析的,但对于“DateTime”或“Exception”等 PHP 基类,我收到错误/注释“DateTime 无法解析为类型”。 PHP 验证版本设置为 7.1,但更低的设置会产生错误。

我该如何解决这个验证问题?

最佳答案

这里有很多种可能的情况;我的是一个相当老的项目,构建路径配置有问题。但是使用 GUI 我无法修复它。

在 eclipse 关闭时将以下行添加到项目文件夹中的 .buildpath 文件,然后重新启动 eclipse 即可解决问题:

<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>

但是,另外,如果代码使用命名空间,则需要使用\DateTime 而不是 DateTime,或者在顶部添加“使用 DateTime”;

(使用 Eclipse PDT does not propose all php functionshttps://bugs.eclipse.org/bugs/show_bug.cgi?id=502184 深入挖掘其他问题的评论后找到的解决方案)

关于php - Eclipse PDT : "<class> cannot be resolved to a type" for default php classes like DateTime, 异常等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45798965/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com