I just wish you had a video for every subject I want to study. You are probably the best youtube coding instructor I've ever seen. Seriously, I've been studying for years.
Yes i was just here to comment the exact same thing. its just the perfect amount needed; not redundant, but not so sparse either that you're still a bit unsure of things.
Even if you talk a lot, it makes things very clear and easy to understand. Some people might complain but I do like how you explain things. I cant wait for you to make Laravel tutorial. Please, make sure to do an example project so we can get the idea on using it for projects. Thank you
I have been thru a few OOP PHP video tutorials, and some were good, but either explained too fast, or high level over views. From what i learned from others, viewing these videos really nailed it for me. They made sense where the others were murky. Now i am ready to convert my procedural code to OOP. Thank you and great job.
This course is amazing. You explain it so well. It's sensitive to those that know php, and are struggling to get their heads around OOP. Thanks so much!
My man, you gained a subscriber. Just started php in my CS study and the OOP was optional for an advanced class. Wanted to be prepared so I'm following it and on the 6th video I can safely say I'm learning shitloads from these short and to the point videos. Keep it up
If I may... You said that destruct occurs when we are done creating an object... That means that you instantiate a class then the construct runs to do the stuff we want it to do or not, and then once it's done the destruct runs... It is not like that.. Destruct run at the end of the script, and not when are are done creating the object.
Nice video. One suggestion, is to do something with the destructor. Now the only thing I know is that it get's triggered already when the class is instantiated, but don't know what it's purpose or functionality would be.
man PHP sure has its quirks: calling a method with the *->* and the *$* when declaring variables/properties is definitely going to take time for me to get used to. I'm so used to the . thanks to C# and JS.
I solved the problem with Karabiner Elements. Shortcut 1: Ctrl+. becomes -> and Shortcut 2: Cmd+. becomes => :-) But yes they should've just used a period!
The destructor does not run at the same time as the constructor. Rather, it runs when the last reference to the object in question is gone, or at the end of the script.
yes i will like what i had to recheck, PHP possesses a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence.
Summary for Java Devs: For constructors, use instead of "public ClassName(String s, int i)" in Java, "public function __construct(values)" in PHP. "$this" is equal to "this" in Java. You can extend classes in PHP just like in Java with "extends". "__destruct" is useless af (it just get's run after the "__construct", so.. use the "__construct" method). Everything else is pretty much the same, privat, public, protected etc.
I just need to mention something about scopes that will be related to object destruction. All variables in the root script are in the same scope even the included scripts will have access to declared variables of their parents. Only functions will have a different scope than the scrip scope. So, with that said, objects are destroyed when they reach the end of their scope. Like instantiating an object inside a function, it will call the object destructor at the end of the function body, of course, unless it's a static variable.
Excellent video, my only thing would be I didn't grasp the concept of destructor, I guess I will watch the video again. Other than that, I am learning loads of information, thank you.
Hi Daniel, I just want to clarify on what will be the sense of putting public $name; If you will have it also in the __construct($name); BTW This is a way way way better series than the others
1:32 The destructor is not executed "right after creating an object" but when the object is deleted. 4:50 You don't have to include parethesis when you have a constructor. You only need to add them if the constructor expects any parameters, which does not need to be the case, you can define the constructor without any passing parameters.
And yes, the destructor is called right before the object is deleted at the end of a script. I am not native English speaking, so when I said “it is run at the end”, I didn’t mean at the end of the class being loaded, but when the object is no longer referenced. 🙂 I can see how it comes off wrong in the way I phrased it there.
I do not fully got how exactly __destruct works. What exactly it destructs? all data for all objects that used this class? Or something else? Or it just runs after the object is done (so we can put some code there that we need to run at the objects work end) and it is destructed automatically?
You such an amazing lecturer, I had taken a course from Edwin Diaz on Udemy, He taught methods, properties, get and set, constructor etc separately because of that I am able to understand the amazing life saver lecture, newbies might be struggling as you compounded all in one go. Thank you so much for your efforts
I know that you Cannot Nest Classes in the general sense of the Word but can you for example Create a Class With A method, Which then has Seperate Classes inside that method. That would make what i'm trying to do a hell of a lot easier... ?
Hello please mine is not echoing as shown in the video is there a chance you linked up the includes file ; because am getting a feedback error on the line
The video is a direct continuation of the last lessons, so yes the include file is linked at the top of the index page. As you can tell in the video, the top line in my index page is line 4 and it has the ?> in it, so there is the same PHP code as in the previous lessons 🙂
Should i always use constructors for initialization, am asking because when i instantiate the person class the constructor expects arguments, so in the tutorial you already have Daniel his age and eye color passed as argument. Should i be initializing my instance with null values then use my regular setter method?... Say initially i want my object to have empty values...
Both are valid ways of using it, the way he presents is called dependency injection, where his objects require some values/dependencies in order to be initiated properly. You can set them to null and then configure them when needed. So one is not better then the other, depends on how you need it
@@TheOneAndOnlyAhmed The properties are private yes, but the constructor method is public. And because we assign the properties using the method this is possible.
Yes, it is just a principle to help you initialize object immidiatelly after it is created. You can just call your own method if you like, constructor is there just for the convenience (standard practice)
Technically, creating an object is done by compiler not methods and constructors. Constructor is not different from regular method, the only think is that if constructor is public, you are guaranteed that it will be called on object creation. So it would be the same as if you called: $myObj = new Obj(); $myObj->myCustomConstructor(); just that the php does $myObj->__construct() for you (same goes for destructor, but before object is going to be destroyed)
Just spent ages trying to figure out why my calls to the constructor weren't working.. always remember to double check where you saved your files, kids! You might be accessing an outdated version!
I think descructor is called later: ---------------------------------------------------------------------- Result: ConstructorDoeis this end?Destructor
Your explanation rocks, but your multimedia sucks. Because it's highly distracting. I've found your tutorials are truly valuable, but hard to concentrate on. I'd like to thank you for your initiatives.
Your procedural course was extremely comprehensible and useful but man, this course sucks. I mean the idea is generally comprehensible but not practicle. You already have a procedural course so there's no need to use a car to explain objects. Instead just jump straight into actual coding, how and why its more efficient than procedural. Its like i have to watch a long long theory of attributes and methods of a car which has nothing to do with programming and very boring and then try to merge it into php again like how to make an sql query from a car, jesus!
For beginners like me, I appreciate very much that Daniel goes slow on the details and repeats why the coding is done certain way. It reminds me from time to time of what has been mentioned in the previous lessons, especially when I binge watch the tutorials. It also helps me to practice along with the tutorials on my own server. If you think that the lessons are slow, just fast forward, that's what the arrow buttons (or the double touch) are for. Daniel, keep up the good work!
I just wish you had a video for every subject I want to study. You are probably the best youtube coding instructor I've ever seen. Seriously, I've been studying for years.
Here from the future to let you know that you did not talk too much and I understood what you said. Thank you for this series!
Yes i was just here to comment the exact same thing. its just the perfect amount needed; not redundant, but not so sparse either that you're still a bit unsure of things.
Even if you talk a lot, it makes things very clear and easy to understand. Some people might complain but I do like how you explain things. I cant wait for you to make Laravel tutorial. Please, make sure to do an example project so we can get the idea on using it for projects. Thank you
You are not talking a lot. Whatever you are doing is perfect. I like your tutorial very much. Best wishes.
Gotta be the best, highest quality PHP tutorials on youtube. Subbed to patreon to then forget about just to pay it back.
Best teacher. Don't stop.
My first programming language is Java because of that OOP concepts are easier to me to understand thank for the tutorial ❤
I have been thru a few OOP PHP video tutorials, and some were good, but either explained too fast, or high level over views. From what i learned from others, viewing these videos really nailed it for me. They made sense where the others were murky. Now i am ready to convert my procedural code to OOP. Thank you and great job.
Great! Now I can finally understand the use of "__contruct()"
Thank you.
Now watching after time again can say this is the best explanation in UA-cam regards of construct and destruct.
OMG your explanations are so clear,you are so helpful I am very grateful that I found your tutorials,May the Lord increase you more and more
Daniel: *making tutorials
also Daniel: I feel like I talk a lot
thanks m8, deadass, my teacher sucked at teaching me this and this series just saved my ass i love you so much
you really teach very wellll wow, you make sure there is no confusion
This course is amazing. You explain it so well. It's sensitive to those that know php, and are struggling to get their heads around OOP. Thanks so much!
Nice and clear videos are easy to watch and learn from, Good Job.
My man, you gained a subscriber. Just started php in my CS study and the OOP was optional for an advanced class. Wanted to be prepared so I'm following it and on the 6th video I can safely say I'm learning shitloads from these short and to the point videos. Keep it up
I use construct all the times but I never use deconstruct.
Explained as expected 😉🤘
mmtuts back at it again with OOP PHP
Thanks a lot for this Dani. It's now making sense for me. I wished I saw this while on uni.
An awsome way to teach PHP OOP, thanks mate, you are great (y)
The Coding Train: Never forget *this dot*
MMTuts: Never forget *this arrow*
fantastic tutorials. I just signed up at patreon as well. Thanks for so much good info.
Best teacher!
If I may... You said that destruct occurs when we are done creating an object... That means that you instantiate a class then the construct runs to do the stuff we want it to do or not, and then once it's done the destruct runs... It is not like that.. Destruct run at the end of the script, and not when are are done creating the object.
omg i'v never thought i would enjoy oop some day thank you Brother
Perfect explaination, clear voice, great examples!
Clear explantation as usual :)
Nice video. One suggestion, is to do something with the destructor. Now the only thing I know is that it get's triggered already when the class is instantiated, but don't know what it's purpose or functionality would be.
Thanks! Hello from Moscow!
Tesla, Space X and now advanced PHP tutorials. Elon is the fountain of knowledge.
Much love from Jamaica!
man PHP sure has its quirks:
calling a method with the *->* and the *$* when declaring variables/properties is definitely going to take time for me to get used to. I'm so used to the . thanks to C# and JS.
I solved the problem with Karabiner Elements. Shortcut 1: Ctrl+. becomes -> and Shortcut 2: Cmd+. becomes => :-) But yes they should've just used a period!
The destructor does not run at the same time as the constructor. Rather, it runs when the last reference to the object in question is gone, or at the end of the script.
Yeah I was wondering, if they both get run at the same time - then how are we getting the value of the properties in the next line..
yes i will like what i had to recheck, PHP possesses a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence.
Great tutorial Danni
Thank you very much..lessons are really interesting and very easy to understand
thank you so much, i have been struggling with this concept.
Perfect
What is the best work around to get over the limitation for overloading constructors?
Thank you boss, we are going to be rich thanks to you. G and L
yeah bro keep dreaming untill faceing the reality
Thanks. Great tutorial
best tutorials
wish for you to live a long life
Summary for Java Devs:
For constructors, use instead of "public ClassName(String s, int i)" in Java, "public function __construct(values)" in PHP.
"$this" is equal to "this" in Java.
You can extend classes in PHP just like in Java with "extends".
"__destruct" is useless af (it just get's run after the "__construct", so.. use the "__construct" method).
Everything else is pretty much the same, privat, public, protected etc.
Thank you so much for your videos!!
I just need to mention something about scopes that will be related to object destruction. All variables in the root script are in the same scope even the included scripts will have access to declared variables of their parents. Only functions will have a different scope than the scrip scope. So, with that said, objects are destroyed when they reach the end of their scope. Like instantiating an object inside a function, it will call the object destructor at the end of the function body, of course, unless it's a static variable.
that was a good one thank you for the clarification.
what is a root script?
Im learning a lot from this course. So much better then the udemy class I paid for!
Do you cover hooks later in this course?
Super Great!!!
i think its better if you practices them also to end the PHP closing tags. It might help them in the future.
You look like a version of Mr. BEAST and Elon Musk combined. And thanks for this series
Excellent video, my only thing would be I didn't grasp the concept of destructor, I guess I will watch the video again. Other than that, I am learning loads of information, thank you.
Thank you!
thank you
Great stuff!!!!=)
@mmtute what kind of laptop you're using here? Is it Lenovo Legion?
Daniel bro god bless you
hi mmtuts can you make some more new html5 videos because i need some because you are the only one who explanes very well
Hi Daniel, I just want to clarify on what will be the sense of putting public $name;
If you will have it also in the __construct($name);
BTW This is a way way way better series than the others
Bro thanks a lot super helpful, appreciate it
1:32 The destructor is not executed "right after creating an object" but when the object is deleted.
4:50 You don't have to include parethesis when you have a constructor. You only need to add them if the constructor expects any parameters, which does not need to be the case, you can define the constructor without any passing parameters.
Hehe I would call it “Wrong!”, but it’s nice to know that they aren’t required 🙂
And yes, the destructor is called right before the object is deleted at the end of a script.
I am not native English speaking, so when I said “it is run at the end”, I didn’t mean at the end of the class being loaded, but when the object is no longer referenced. 🙂 I can see how it comes off wrong in the way I phrased it there.
@@Dani_Krossing Despite all of that, I very much enjoy your lessons and the way you have organized them.
Thank you alot for this tutorials
Legend thank you 👊🏼
🤙
So, this is like setters and getters?
fantastic!
I do not fully got how exactly __destruct works. What exactly it destructs? all data for all objects that used this class? Or something else?
Or it just runs after the object is done (so we can put some code there that we need to run at the objects work end) and it is destructed automatically?
Thank u mate
You such an amazing lecturer, I had taken a course from Edwin Diaz on Udemy, He taught methods, properties, get and set, constructor etc separately because of that I am able to understand the amazing life saver lecture, newbies might be struggling as you compounded all in one go. Thank you so much for your efforts
Just a feedback that you spoke most about what to do and how to do. But, did I miss why to do? please review.
I know that you Cannot Nest Classes in the general sense of the Word but can you for example Create a Class With A method, Which then has Seperate Classes inside that method. That would make what i'm trying to do a hell of a lot easier... ?
Could you provide an example of when you would have a PHP constructor ( _construct) using a get or post method with a HTML Form element ?
👌 Great.
Thank you very much! Where can I donate?
Tattooed Elon Musk haha. Btw great lessons sir!!
Hello please mine is not echoing as shown in the video is there a chance you linked up the includes file ; because am getting a feedback error on the line
The video is a direct continuation of the last lessons, so yes the include file is linked at the top of the index page. As you can tell in the video, the top line in my index page is line 4 and it has the ?> in it, so there is the same PHP code as in the previous lessons 🙂
Should i always use constructors for initialization, am asking because when i instantiate the person class the constructor expects arguments, so in the tutorial you already have Daniel his age and eye color passed as argument. Should i be initializing my instance with null values then use my regular setter method?... Say initially i want my object to have empty values...
Both are valid ways of using it, the way he presents is called dependency injection, where his objects require some values/dependencies in order to be initiated properly. You can set them to null and then configure them when needed. So one is not better then the other, depends on how you need it
Its Great, you are using touch pad only
Can I ask help what should I do for echo to show all the properties ?
Create a method that you will return all the properties inside there and just call this method on the inddx page
get_object_vars($object), an in-built PHP function
Is the __construct() always public? Why not private? Thanx for the video.
Try it out :) "Learning by doing"
If it private how can you set values to the variables when you make object of the class?
@@TheOneAndOnlyAhmed The properties are private yes, but the constructor method is public. And because we assign the properties using the method this is possible.
Is constructor important or necessary?I mean can we work without it using oop standards?
Yes, it is just a principle to help you initialize object immidiatelly after it is created. You can just call your own method if you like, constructor is there just for the convenience (standard practice)
remember me homie
damn i understood OOP faster than procedural programming
SUPER
What's the difference between methods and constructor?
By both ways we can create object
Then what's the difference?
Technically, creating an object is done by compiler not methods and constructors. Constructor is not different from regular method, the only think is that if constructor is public, you are guaranteed that it will be called on object creation. So it would be the same as if you called:
$myObj = new Obj();
$myObj->myCustomConstructor();
just that the php does $myObj->__construct() for you
(same goes for destructor, but before object is going to be destroyed)
Is that a Jin Tattoo on your right arm? (Tekken)
Return 'Thank you';
Where is destruct method?
Better null than undefined.
Just spent ages trying to figure out why my calls to the constructor weren't working.. always remember to double check where you saved your files, kids! You might be accessing an outdated version!
you started saying about destruct, then jumped to something else. how to use destruct?
To better understand the __destrust method:
class A {
protected $id;
public function __construct($id)
{
$this->id = $id;
echo "construct {$this->id}
";
}
public function __destruct()
{
echo "destruct {$this->id}
";
}
}
$a = new A(1);
echo "-------------
";
$aa = new A(2);
echo "=============
";
The output content:
construct 1
-------------
construct 2
=============
destruct 2
destruct 1
Dude your videos are AWESOME! i think i have a crush on u xD
12:03 playing Jazz piano again?
yeah but I have to admit I actually find his way of using hands to talk to be engaging.
I think descructor is called later:
----------------------------------------------------------------------
Result:
ConstructorDoeis this end?Destructor
_Elon Musk_ .... come from your real channel
Зашёл посмотреть и что вижу: Даниель, голубой и ему 28.
Is he German ?
OOP is overly abstracted nonsense.
It kind of is.
Kind of yes, but it adds a common coding standard.
@@Kakaohunden define a common coding standard??
You are in the wrong place
gl in your future endeavors
Your explanation rocks, but your multimedia sucks. Because it's highly distracting. I've found your tutorials are truly valuable, but hard to concentrate on. I'd like to thank you for your initiatives.
Your procedural course was extremely comprehensible and useful but man, this course sucks. I mean the idea is generally comprehensible but not practicle. You already have a procedural course so there's no need to use a car to explain objects. Instead just jump straight into actual coding, how and why its more efficient than procedural. Its like i have to watch a long long theory of attributes and methods of a car which has nothing to do with programming and very boring and then try to merge it into php again like how to make an sql query from a car, jesus!
If I go too slow for you then there are many other channels who takes less time "dumbing things down" and instead go straight to coding :)
these tutorials are great. you don't know what you are saying man. so just shut your mouth
For beginners like me, I appreciate very much that Daniel goes slow on the details and repeats why the coding is done certain way. It reminds me from time to time of what has been mentioned in the previous lessons, especially when I binge watch the tutorials. It also helps me to practice along with the tutorials on my own server. If you think that the lessons are slow, just fast forward, that's what the arrow buttons (or the double touch) are for.
Daniel, keep up the good work!
Thank you