Call to a member function on a non

This question already has an answer here:

  • Reference - What does this error mean in PHP? 30 answers

  • It means that $objPage is not an instance of an object. Can we see the code you used to initialize the variable?

    As you expect a specific object type, you can also make use of PHPs type-hinting featureDocs to get the error when your logic is violated:

    function page_properties(PageAtrributes $objPortal) {    
        ...
        $objPage->set_page_title($myrow['title']);
    }
    

    This function will only accept PageAtrributes for the first parameter.


    There's an easy way to produce this error:

        $joe = null;
        $joe->anything();
    

    Will render the error:

    Fatal error: Call to a member function anything() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/casMail/dao/server.php on line 23

    It would be a lot better if PHP would just say,

    Fatal error: Call from Joe is not defined because (a) joe is null or (b) joe does not define anything() in on line <##>.

    Usually you have build your class so that $joe is not defined in the constructor or


    $objPage不是实例变量,或者您正在用不是PageAttributes类的实例的某个东西覆盖$objPage

    链接地址: http://www.djcxy.com/p/69390.html

    上一篇: PHP如何修复注意:未定义的变量:

    下一篇: 调用非成员函数