PHP Call to a member function on a non-object
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Call to a member function on a non-object

  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Call to a member function on a non-object

    Hello,

    First of all , I appreciate from your perfect forum,I just joind. and This is my first post.

    I study some tutorial video on PHP-OOP but I faced some errors and misunderstood.

    1- The misunderstood is below:

    $user = User::find_by_id(1);
    echo $user->full_name();

    the find_by_id() method is a statical method but full_name is not so. hence we need to instantiate User class but in that video, he does not instantiate it.

    2- The error I faced it :
    Fatal error: Call to a member function full_name() on a non-object

    I write the script like him but he could run it by i could not. I ask the masters, help me to find my mistake.

    meanwhile I attached my script and Kevin's script to this post.
    Attached Files Attached Files

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,865

    Re: Call to a member function on a non-object

    1. What exactly is your problem with #1?

    2. Means the variable you are treating as an object is not yet created, or is not of the object type.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Oct 2011
    Posts
    3

    Re: Call to a member function on a non-object

    Hi PeejAvery,

    Thank you for your reply.

    But this is a right code and does work, but unfortunately It does not work for me.

    It use a higher level of oop that does not need to instantiate.

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,865

    Re: Call to a member function on a non-object

    I'm sorry, but you have in no way clarified what you mean with #1.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center