October 23rd, 2011 02:11 PM
#1
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
October 23rd, 2011 04:36 PM
#2
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.
October 23rd, 2011 05:42 PM
#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.
October 23rd, 2011 07:15 PM
#4
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
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks