In this OOP PHP tutorial I will teach you about Constructors and Destructors which are used to run statements right before or after a class has been instantiated.
Link to this playlist:
➤ GET ACCESS TO MY LESSON MATERIAL HERE!
First of all, thank you for all the support you have given me!
I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful 🙂
Material for this lesson:
Nguồn: https://quydinh.com
Xem thêm bài viết khác: https://quydinh.com/game
Xem thêm Bài Viết:
- Định nghĩa Hell Elo là gì và cách thoát hell elo cho người mới chơi LMHT
- Hướng dẫn đăng ký elsword qua 3 bước đơn giản cho những người mới
- [Topgame] Top 9 game RPG “Cày Cuốc Fam Đồ” free cho máy tính cấu hình thấp | #3
- Tera Classic Mobile – Siêu phẩm MMORPG CỰC KHỦNG – 6GB! NTVG#12
- LỚP HỌC CÁ BIỆT | ThắnG Tê Tê Ngày Đầu Tiên Làm Cô Giáo | Virtual High School Teacher 3D
Thank you boss, we are going to be rich thanks to you. G and L
What's the difference between methods and constructor?
By both ways we can create object
Then what's the difference?
Thank u mate
Can I ask help what should I do for echo to show all the properties ?
Man! You have a natural gift as a teacher. You should create a PHP course on Udemy. You will have more impact on the developer's community. Keep it up!
Perfect explaination, clear voice, great examples!
Is constructor important or necessary?I mean can we work without it using oop standards?
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…
thank you so much, i have been struggling with this concept.
12:03 playing Jazz piano again?
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.
thanks m8, deadass, my teacher sucked at teaching me this and this series just saved my ass i love you so much
Dude your videos are AWESOME! i think i have a crush on u xD
Thank you alot for this tutorials
Bro thanks a lot super helpful, appreciate it
@mmtute what kind of laptop you're using here? Is it Lenovo Legion?
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.
Is that a Jin Tattoo on your right arm? (Tekken)
Dude your videos are AWESOME! Thanks so much for sharing this knowledge! FYI '-' is formally called a hyphen but $is_it_also->hyphen("-") also returns true. Sorry I couldn't help myself. I call it a dash more than not
The Coding Train: Never forget this dot
MMTuts: Never forget this arrow
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.
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.
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.
fantastic tutorials. I just signed up at patreon as well. Thanks for so much good info.
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 ?
🙏
Its Great, you are using touch pad only
I think descructor is called later:
<?php
class Person{
private $name;
public function __construct($name){
$this->name = $name;
echo 'Constructor';
}
public function __destruct(){
echo 'Destructor';
}
public function setName($name){
$this->name = $name;
}
public function getName(){
echo $this->name;
}
}
$person = new Person('John');
$person->setName('Doe');
$person->getName();
echo 'is this end?';
?>
———————————————————————-
Result:
ConstructorDoeis this end?Destructor
You are not talking a lot. Whatever you are doing is perfect. I like your tutorial very much. Best wishes.
SUPER
Thank you very much! Where can I donate?
Зашёл посмотреть и что вижу: Даниель, голубой и ему 28.
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