简体   繁体   English

调用类中的未定义方法,即使已定义

[英]Call to undefined method in class even when it is defined

I am getting the following error message turning up in my apache error logs: 我的apache错误日志中出现以下错误消息:

PHP Fatal error: Call to undefined method MyWebsite\\Model\\ContentMedia::getImagePath() in /var/www/www.website.com/application/libraries/MyWebsite/Model/ContentVersion.php on line 544 PHP致命错误:在第544行的/var/www/www.website.com/application/libraries/MyWebsite/Model/ContentVersion.php中调用未定义的方法MyWebsite \\ Model \\ ContentMedia :: getImagePath()

On line 544 of ContentVersion.php the call is made: ContentVersion.php的第544行上进行了调用:

$cm->getImagePath('img', 'small');

The ContentMedia class extends another class called Model that does have that method: ContentMedia类扩展了另一个名为Model类,该类确实具有该方法:

class ContentMedia extends \MyWebsite\Model{

... the Model class: ... Model类:

namespace MyWebsite;

class Model{

    public function getImagePath($field, $size = null){

        ...
    }

I get this error show up every now and then in the log files, so it may be one particular instance where a user comes across this, but I don't know where. 我不时在日志文件中显示此错误,因此可能是用户遇到此错误的一个特定实例,但我不知道在哪里。 This method is used throughout the site and it works. 该方法在整个站点中都可以使用,并且有效。 If the method is definitely defined how can this error be thrown? 如果明确定义了方法,如何抛出该错误?

I thought about checking the access logs to match an exact requested URL to the timestamp of the error, but the access logs are insanely large of course, so any advice as to how to output just a chunk of time from a large access log would be amazing. 我曾考虑过检查访问日志,以将请求的确切URL与错误的时间戳进行匹配,但是访问日志当然很大,因此,有关如何从大型访问日志中仅输出大部分时间的建议是惊人。

I am using Doctrine 2 and Codeigniter 2. 我正在使用教义2和Codeigniter 2。

My first thought is to check that you definitely have an instance of model present within the script. 我的第一个想法是检查脚本中是否确实存在模型实例。 Have you tried creating another function for the sake of testing that will just echo something like "Object is instantiated and inherited functions properly". 为了测试,您是否尝试过创建另一个函数,而该函数只会回显类似“对象已正确实例化和继承的函数”之类的信息。

That way we might be able to narrow down the problem a little 这样,我们也许可以缩小问题的范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使在AJAX调用中明确定义,PHP也说未定义? - PHP says Undefined even when it is clearly defined in AJAX call? 未捕获的错误:调用未定义的方法stdClass :: update(),即使该方法已定义 - Uncaught Error: Call to undefined method stdClass::update() even though the method is definitely defined 调用未定义的函数错误,即使函数已定义 - Call to undefined function error even function is defined PHP:“调用未定义的方法”......但方法是否已定义? - PHP: “Call to undefined method” … but method is defined? PHP 致命错误:调用未定义的方法,即使该方法存在于主类中 - PHP Fatal Error: Call to undefined method even though the method exists in the Main Class $_POST 的未定义索引,即使已定义 - Undefined Index with $_POST even when defined laravel 路线未定义,即使路线已定义, - laravel routes undefined even when route is defined, 调用类方法时“调用未定义的函数”错误 - “call to undefined function” error when calling class method 即使已定义功能,也会出现“致命错误:调用未定义的功能” - “Fatal Error: Call to undefined function” even though the function is definitely defined PHP - 定义时调用未定义的函数 - PHP - Call to undefined function when it is defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM