2 Attachment(s)
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.
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.
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.
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.