Learn Object Oriented PHP for Beginners | With Examples to Help You Understand! | OOP PHP Tutorial
Вставка
- Опубліковано 9 чер 2024
- Today I will teach you all the basics of Object Oriented PHP for beginners. 🙂 I tried making this the EASIEST Object Oriented PHP video on UA-cam. This video will focus on not just showing you HOW to write OOP PHP, but also how to USE it, so you know exactly how to replace your existing Procedural PHP with Object Oriented PHP!
➤ CHAPTERS
00:00:00 - Introduction to OOP PHP!
00:03:45 - How to create a class in PHP
00:07:47 - Properties and visibility modifiers in OOP PHP
00:13:58 - Constructors in OOP PHP
00:18:03 - Instantiate objects in OOP PHP
00:20:53 - Access properties and methods in OOP PHP
00:22:48 - Methods in OOP PHP
00:26:28 - Create PHP objects anywhere
00:28:29 - Create getter and setter methods in OOP PHP
00:37:17 - How to use OOP PHP instead of Procedural PHP
➤ GET ACCESS TO MY LESSON MATERIAL!
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 and UA-cam Memberships to share improved and updated lesson material, and for a small fee you can access all the material either from my memberships or Patreon, depending on your preference. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful :)
Memberships: / @dani_krossing
Patreon: / mmtuts
"Believe me, I prayed to God that you would do an explanation of OOP. When searching for an old course for you, I found that you have done it. Thank you. From Egypt, Alexandria."
Are you from Egypt? I was supposed to travel Egypt soon 😅
@@X-factor6you are so creepy
Me too 🙂❤️
I didn't understand OOP in my first language and i understand this so easily with you , The issue is not in the language or the difficulty of the topic or my mind. I think it is in the simplicity of the style and the conscience of the person who explains. Thank you for your great effort.❤❤❤
Huge fan! You have very natural way of explaining these things! Waiting for more Laravel tutorials!
Dani has a gift of making the difficult and challenging seem so easy. This is one of the, if not the best OOP tutorials on the planet. Thank you for sharing your knowledge in the subject area. Look forward to more tutorials.
Thank you so much 😊
This is such an awesome video. You don't just have the coding skills, but the communication skills as well. You approach from my vantage point -- procedural style. Then you show the differences, giving the how and why. Thank you for helping me finally start wrapping my head around OOP!
I'm so glad I found your page! You're helping a lot with your clear explanations. The best teachers are those who put themselves in the shoes of total beginners, and you're doing it so well.
Thank you very much
you are the G.O.A.T
Very good video, thanks for sharing. I was missing seeing oop implemented in a practical example. So I appreciate the second part of this video.
Making the jump from procedural to OOP - thank you for this video!
Thanks Danni for gracing us with another great tutorial,highly appreciated😊
Excellent video. I pray that you will create a Laravel tutorial, and if it happens, I'm thrilled. Thank you once more for your tutorials, Dani. I gain a lot of knowledge. MABUHAY ka meaning I SALUTE you in filipino.
I couldn't possibly thank you enough for this video. The way nothing goes unsaid is remarkable in helping me understand every point without question! You are the best teacher I have come across yet!!
I finished this playlist, and I'm so glad. PHP is very much the same as Javascript and others; it's just different to write. Thank you so much for sharing the knowledge.
I don't understand why this video has only 20k views. It's a free and great course. Maybe this language isn't that popular, and I made a mistake learning it. I hope I'm on the right web development path.
PHP is the top backend language for web devs, seeing that more than 80% of all websites are made with it 🙂 so you are not on the wrong path.
Yet another fantasitc video, i've looked at a lot of other videos for learning PHP, in particular OOP and how I can apply what I already know with proceedule PHP and re-factoring my code into OOP. Your style of teaching is amazing and for me makes much more sense, thank you :-)
Glad to have you back on coding tutorials. Best UA-camr out there for anyone who wants to learn about coding and security at the same time. I love mmtuts 😅
Love your explanation and teaching style!
Thanks ... always VERY helpful!
What kind of teacher you are ?! Thanks a lot for your efforts. Please make a Laravel Playlist if possible: It will be a fantastic journey for your subscribers and fans like me. (I sometimes click ads on your videos intentionally as a small sign of gratitude for what you are delivering. This is the minimum thing I can do :)
I learned a lot from you, mmtut, back in 2016/17/18 when I started Web Development. Your tutorials helped me with all the fundamentals of designing website and building PHP websites. Even though I'm more of a JavaScript developer now, but I do miss your tutorials a lot. So happy to see your tutorial again. I'll definitely give some attention to PHP again so I'll build up my skills in PHP again and then move to Laravel.
It would be great if you could do some advance tutorials on Laravel for PHP developers in your channel.
Thank you so much for your tutorials and inspirations and all I learned from you. If I'm proud to be good in Web Development today, you helped set me up for who I'm today. Thank you and God bless you, Dani Crossing.
Can u suggest me some good channel for JS...
@@SanyamJain08 Channel: Namaste Javascript
you are so awesome!! thanks for the playlist!
I needed to seen an example with forms and OOP relation but this helps too, thanks much.
i really understood how to code poo in php, i just found gold in your tutorials! thanks man!❤❤
Thank you for this course❤
I watched your video, tutorial, about OOP and for the first time everything, from 1st sec till the last is crystall clear and easy to understand. Hope you make more videos and tutorials. Thank you!
Wow, thank you so much for this video. You have literally opened my mind to new possibilities and much better coding practices.
Thank you for your amazing teaching skills!:)
Thank for this precious tutorial ❤❤❤
Wow the way you explain the code makes it so easy to understand definitely learned a lot from your video thank you very much
thank you so much!!!!!
Well explained. Thanks bro.
Hi Dani! It's amazing how you keep improving the video series you already made, by making them again completely!🤯 I was wandering if you maby like to make a forgotten password system with OOP in the future? 😁 Have a nice weekend!
Thanks alot for the explanation our teachers at school always link towards your channel to understand things better
Thanks a lot sir 🙏.
It will help a lot, you are a great teacher.
We have just stared learning php oop in university I just found your course in UA-cam 😊thanks bro 😎 form Afghanistan 🇦🇫
Thanks 😊👍
Thank you!
I love so much Danny. Thanks for your videos. We've been doing a lot of log in systems and Its almost like that's the only thing to do with PHP. Please can you do more projects with PHP this time
Thank you Dani. A lot of Love from Mali 🙏
Great channel.
Have last exams in a few weeks and literally cant get anything from my profs presentations (they are very minimalist) so rly tysmm
Thank you Mr. Dani for this very useful course , you really made a hard efforts
Excellent Explaination!!! I really appreciate You Sir!!! ❤❤ From Pakistan
Thanks Dani, it was a nice course! I think i'm ready to get into some wordpress now)
mad man this thing was so catchy able to get the lesson way better than other videos thank you for the teachings idol god bless you more :)
Top content
Thank You sir
Nice one!
Love you from Pakistan
Please create simple Wordpress plugin by using OOP concepts
good job bro😍😍😍😍
thank u dani!
thank you
Hello Dani, I learned to use the MVC model with your tutorials a couple of years ago, I appreciate everything you teach in your videos, there is something that I could never do on my own and I researched it a lot but I can't find a way to do it. Using OOP and MVC, how do I ensure that a function that performs an INSERT in the database returns the ID of that INSERT? I tried every way to use lastInsertId but it doesn't work for me. Could you give me a hand with that? thank you.
Thank you Sir, please start Laravel series I'm waiting for this. ❤
I never knew that mr. Beast is a literal beast in programming 😂 Great content! New sub here!
Hey! As i can see you get a desk that can adjust its height. Im beginning to study informatics and also im gaming alot and just wanted to ask you, if you could recommand a desk? Because also im moving out and im gonna get a fresh setup anyways :D Would you say those desks are worth their money?
Thank you so much! Making PHP easier.
May I draw the conclusion; a login-systeem with OOP is safer way than with procedural PHP? Or just an other way to do it?
Gold!
Platin! 🙂
I applied to PHP developer, even though I don't have lot of PHP knowledge, and they got back to me from the company.
So I started learning from your tutorials and it helped me so much! THANK YOU!
I have 1 question about OOP Encapsulation.
How by using PUBLIC getters and setters I am hiding data from the user? He can just use the getter and the setter to change private fields in the class. 😬
The user can’t access anything unless we allow them to 🙂 that’s why we use PHP, since it is a server side language, meaning the user can’t access the code.
The reason we use getter and setters, are for our own benefits as the developer, since it allow us to have more control over how we get and set fields 🙂 not for the sake of the user.
Thnx for the tutorials, when au starting laravel series?
The amount of code that OOP can save is very high when citing generic classes and inheriting to more specific classes. That being said, there is a maintenance price for inheritance and polymorphism.
Hey Dani! I wrote a series of codes years ago using functions instead of classes, and that's a habit I kept. In terms of speed (execution) which is the best route? Functions or Classes? Thanks for what you do!
Functions are faster because it involves less encapsulation, however you need to consider the purpose of your code rather than speed, when we talk about "when to use classes or functions".
For example, if you need something like a login feature, then because of the scale/size of that feature, it is better off to use classes.
However if you just need a simple feature to show the current time on your website, then it would be overkill to use classes.
So it's not about "if you should use classes or functions". It's about "what tools best suits the task". 🙂 I see too many PHP developers argue about "Procedural vs OOP", and they all completely miss the point. It's like arguing about "if a screwdriver or a drill is the better tool", which is silly since they each have their uses.
@@Dani_Krossing Excellent. I basically use functions with APIs and Curl so I will not touch them then. I was asking about "execution speed" because I mostly interact with trading platforms, which require excecutions to be as minimal as possible :) Thanks again, Dani!
The vid was good
Quick question.. can we create this in wordpress functions.pho to handle wp errors ?
Thank Dan Drop likes from Africa please
In the futur you create tutorial for Laravel or Symfony for learn the next step in OOP PHP ?
And thank's for you video :) It's perfect for understand the base of OOP simply. When a for advanced OOP ?
I hope you create a tutorial about the foreign keys I see that you used it on the comment tables :D, thank you from Philippines.
In applying as a php developer, is it very important to master DSA? cause I think it would be better, especially these comes up with so many logics.
dani is genius
please do not advise me, I am trying to make bones for a character in unity with a PNG image in the skinning editor, but when I try to move with them or adjust the structure of the body in edit geometry, copying starts as soon as I press the mouse.
Yessss
"Hi Dani,
I trust you're doing well. I've been working on developing a PHP script and I want to ask you something. I'm interested in implementing a server-side activation mechanism to ensure that users need to interact with my website or server before the script can be fully activated and used. Additionally, I want to make it challenging for users to modify or bypass the activation mechanism and ensure that I have remote control over the activation process.
Could you please provide guidance on how I can build such a mechanism? Specifically, I'm looking for advice on:
1. Implementing the activation logic within the PHP script.
2. Enhancing security measures to prevent unauthorized modifications or bypassing of the activation mechanism.
3. Establishing remote control over the activation process to enable/disable script functionality as needed.
Thank you in advance for your help!
❤
48:36
incase somebody had the query fatal error it's because there's a typo in the sql query, just remove the single quote signs from around the table names
from: ('username', 'pwd')
to: (username, pwd)
Please make a Laravel Tutorial. I'd be very interested
Bro ily
Dani should you use the getter and setter methods within the constructor?
No you can just assign the data directly to the properties 🙂
Actually you should use setters in the constructor if you have validation in the setters.
Where are you Dani? Where's your tutorials, they really helping me! When new videos, miss you
thank you man so much
and i have a question
55:50 why you make it public and you don't make it protected ?
It’s because signupUser() needs to be accessed from a normal PHP file, when creating the object. 🙂 Protected we use, when only parent classes should have access to the method. So “a class accessing methods from another class”.
😘
sir we need more like how to use Ajax in php
you are the best🤍
47:16 How does it recognize the Dbh class even though we didn't include "Dbh.php"?!!
Please answer Dani ❤
We include the class later, when we need include both classes into the page we need to use them in. 🙂
I couldn't find anything on polymorphism, or maybe I missed out somewhere from your content. Could you guide me here
Mission accomplished, the taskbar is full. 😂
I don't know how you don't get lost with all those icons.
You can directly find apps from the start menu, press the flag key and type the first few letters and hit enter. 😉
😂 I like my taskbar chuck full of shortcuts though
@@Dani_Krossing you're a savage hehe
Classes tend to misbehave while sending data keys into database and API responses
That isn't directly related to classes though. It's more of a "poorly written code" issue you are describing. 🙂
I would stick to procedural because it’s faster and straightforward; not complicated
Procedural is great for smaller PHP features on a website, however the more complex a website gets, the more complex and less scalable it gets if you use Procedural PHP. 🙂
It is only early on, that Procedural appear “less complex”, until the moment the developer stands with a more complex website in front of them. 😊 At that moment, OOP is worth doing since it makes the code more structured. So while OOP makes the code itself more complex, the overall project becomes less complex through the usage of OOP.
Additionally, if you plan to work with PHP in any professional capacity, then OOP PHP becomes mandatory, since frameworks tend to use OOP.
@@Dani_Krossing Would you recommend trying OOP in vanilla Php before jumping into a framework ?
Can anyone tell me how to download the material i cant find it
It’s at the bottom of the video description 🙂
thanks for the replay @@Dani_Krossing
i wish u wouldve provided some better examples to which OOP is better suited. the sign up example that u provided is essentially procedural code inside an object, which seems redundant or like unnecessary complexity
really the only benefit of adding this extra complexity is the modularity of it
I miss the old mmtuts branding! 😥
The only difference was the name 🙂 I still make the exact same content and everything.
Always remember that a 'method' is not a function and it is written:
function name();
You can see at a glance that it is NOT a function.
I hope that is all clear now.
capo!
Why does everyone who shows OOP take the car's example? How tf should I use that on my website? I don't have cars in my HTML... Wouldn't it be better to show examples with DB connection? Text-areas? Other things? Why cars?
It's because you need to understand "how OOP works". You gotta learn to walk, before you learn to run. 🙂
"Everyone" shows the car example, because it's a great way for people to understand how OOP works. If we just started teaching our viewers "practical examples" immediately, then it would fly over 80% of peoples heads, and they wouldn't learn OOP properly...
Also... I'm guessing you didn't finish my video before commenting, seeing you are asking "why we don't show stuff like DB connection" hehe... 😉 I understand that OOP can be frustrating, but I promise that everyone feel that way at the start, and eventually it will seem extremely easy compared to Procedural PHP. Just keep cool, and take things one at a time, and trust the process when "us teachers", decide that it is best to learn the car example when starting out. 😊
@@Dani_Krossing yes, but you can show starting examples with HTML DOM objects. Because we all use websites every day, and cars are real-life objects, so it is not truly helpful. And I am cool. Come on, I am learning OOP for free on Saturday, so that's awesome! 😁👍 I am just tired of the car's example. At least it could be girls...
@@Alfenijonas 👱♀👱♀👱♀
Is it only me but there's no hyperlink in "➤ GET ACCESS TO MY LESSON MATERIAL HERE!" ?!?
It's a header. Go further down :)
Why use OOP in PHP ??
What are the advantages ??
ua-cam.com/video/8yW0zxhO89g/v-deo.html&ab_channel=DaniKrossing
I can't not think of classes like css classes. Css ruined it for me.. don't learn CSS until you learn php i guess.
It’s funny you mention it, because it never occurred to me they were the same names until now 😂
@@Dani_Krossing haha thanks for the reply! I love your content! Great stuff!
oop is the devil
People always think that, until they start using it for larger projects, where Procedural PHP is a nightmare. 🙂
@@Dani_Krossing been doing this 30 years. I stand by my statement.
still confusing
AN error, AN object
I’ll take it as a complement if that was the only feedback 😂