Static Properties & Methods In Object Oriented PHP - Full PHP 8 Tutorial

  Рет қаралды 27,953

Program With Gio

Program With Gio

Күн бұрын

In the first section of the course, you learned about variable scopes & static variables. In this lesson, you will learn about static properties & methods of the class with some use cases including singleton & factory design patterns. There are few differences between static properties & non-static properties, one is that static properties are associated & belong to the class itself & not to any particular object, while non-static properties are associated & belong to the object. So when you create an object, that object gets fresh values for the non-static properties. Another difference is that you need to use the dollar sign when accessing static properties, unlike regular properties where you don't use the dollar sign to access non-static properties.
SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
👍 Smash the like button
🤝 Subscribe to the channel & turn the notifications on
💬 Post comments, any feedback is greatly appreciated
⭐ Become a Patreon: / programwithgio
THANK YOU!
LESSON 2.7
Course Outline - github.com/gge...
Course Playlist - • Learn PHP The Right Wa...
RESOURCES
Video About Static Variables & Scopes - • PHP Variable Scopes - ... &t=193

Пікірлер: 88
@federicobau8651
@federicobau8651 2 жыл бұрын
Best PHP and complete course. Better than many paid bootcamps and best quality
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌
@tolebiGamingTime
@tolebiGamingTime 10 сағат бұрын
Cool course, I'm waiting for the video lesson on microservices)
@damiankrupa710
@damiankrupa710 Жыл бұрын
Dear Gio! Your course is a masterpiece. It has been deeply thought out in terms of didactics. I have great respect for you for not succumbing to the curse of knowledge. A lot of professional teachers do this (they've forgotten what it's like to not know something) and it makes students like me really feel empowered and feel... a bit smart. In my humble opinion there are many advantages to your course, including: - didactic order; - substantiveness, - lack of boasting and talkativeness, - brevity and modest expression of recommendations, - consequence, - high quality video/audio material, - a large amount of material, - sharing on YT and not on Udemy. Great respect Sir. P.S. Please continue this activity. Your devoted subscriber.
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you so much 💙💙🙏🙏
@erensrtky
@erensrtky 6 ай бұрын
i am using php around 7 years but this course hit me hard in context of dunning kruger effect :)
@ProgramWithGio
@ProgramWithGio 5 ай бұрын
Its one of the reasons why I made this course because I had that same feeling even with many years of experience with PHP. So I started from scratch & learned quite a few new things along the way. Nothing wrong with that. We are always learning
2 жыл бұрын
20 years using PHP professionally, this course is AMAZING, the best PHP course I've found. My 2 cents: use a white theme, when trying to focus on the left side (IDE) I get a flash from the right side (browser), try it yourself, cover the right side with your hand you will see how you can focus better on the code on the left side.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌. I am not a fan of white theme but I might try it out
@zeeu
@zeeu Жыл бұрын
or maybe try: body {background: gray}
@JohnnyBigodes
@JohnnyBigodes 3 жыл бұрын
Just here to give you a like and maybe spread this course a bit more. Thanks
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Thank you 🙏
@basilistigris640
@basilistigris640 Жыл бұрын
each video learn so much i thought i already knew, professional and unique PHP series, thank you Gio, have best luck, you are top notch teacher!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Glad you like them, thank you 💙
@codinginstitution1742
@codinginstitution1742 Жыл бұрын
This Gio is something else
@ProgramWithGio
@ProgramWithGio Жыл бұрын
🙌🙌
@benderbg
@benderbg Ай бұрын
Fantastic video.
@ProgramWithGio
@ProgramWithGio Ай бұрын
Thank you very much!
@TurntableTV
@TurntableTV 6 ай бұрын
Hi Gio! Thank you so much for these videos. They are an amazing resource. I'm in the process of upgrading a 5.4 codebase to php 8.x (haven't touched PHP since 5.4) and this content is golden. At first I was thinking of using Rector as way of automating the upgrade but where's the fun in that? I found your videos and (re)fell in love with PHP.
@ProgramWithGio
@ProgramWithGio 5 ай бұрын
That's awesome. Yes upgrading from 5.4 to the latest version can be challenging but it can also be fun depending on the size of the app. Using Rector could be beneficial in speeding things up but I would also double check things and not rely on Rector fully. I would also upgrade gradually and not all the way at once from 5.4 to 8.x, go from 5.4 to maybe 7 right away, then 7 to 7.1 or 7.3 whichever has more breaking changes & so on. If you have test suites for 5.4 that will be great because you can update version of PHP & run tests and see what fails. Also depending on your dependencies you will need to update those as well. Good luck & have fun
@Vitalii-m6r
@Vitalii-m6r Жыл бұрын
Thanks again for these informative and useful videos!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're welcome
@Leaf256
@Leaf256 Жыл бұрын
RESPECT!👊
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thanks 💙
@keremardicli4013
@keremardicli4013 Жыл бұрын
So valuable lessons...
@ProgramWithGio
@ProgramWithGio Жыл бұрын
🙌🙌
@guillermofernandez2247
@guillermofernandez2247 2 жыл бұрын
I understand why you use static function as callback, but..., which would be an example of use case for not letting use "$this"?? I'm not seeing.... Great course!! Great videos!! Great explanations!! Great everything!! Please let me know if some day you do a course focus on Design Patterns Thanks in advance
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
To avoid hard to find bugs. Accessing $this within closure should rarely be needed. Thank you 💙
@jeevachaithanyansivanandan
@jeevachaithanyansivanandan 3 жыл бұрын
A request : please do a video explaining method chaining, including static methods. Thank you
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Added to the list of topics to cover 👍
@jeevachaithanyansivanandan
@jeevachaithanyansivanandan 3 жыл бұрын
@@ProgramWithGio Thank you, Tutorial Requests 1. Design Patterns and best practices, when to use 2. SOLID principle in PHP - best practice 3. Traits, Interfaces - a simple guide I am sorry if I ask too much :)
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
@@jeevachaithanyansivanandan those are already part of this course. Some design patterns and SOLID principles will be covered as well as interfaces and traits. Might do a separate series about more in depth on design patterns later 👍
@techatival
@techatival 3 жыл бұрын
Thank you!
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
You're welcome 👍
@ilya_123__
@ilya_123__ 10 ай бұрын
Thank you Gio! It is amazing course!
@ProgramWithGio
@ProgramWithGio 10 ай бұрын
Glad you like it, thank you
@omaryahia
@omaryahia 11 ай бұрын
Amazing as always! 🌟
@ProgramWithGio
@ProgramWithGio 11 ай бұрын
Thank you
@memack101
@memack101 2 жыл бұрын
Thank you.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
🙌
@jeevachaithanyansivanandan
@jeevachaithanyansivanandan 3 жыл бұрын
Another good tutorial ;)
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Thank you 🙌
@TerjeNesthus
@TerjeNesthus 2 жыл бұрын
Thanks for making this!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome
@FranciscoJunior29
@FranciscoJunior29 2 жыл бұрын
Very good. Thanks for share.
@invgreat5608
@invgreat5608 Жыл бұрын
Thank you!!!!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're welcome
@WhiteSiroi
@WhiteSiroi Жыл бұрын
thank you
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're welcome
@ezekielnizamani185
@ezekielnizamani185 Жыл бұрын
Hello bro this hizqeel i think it would be great if you create playlist for OOP. love your content you have put everything in course
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Hey, OOP is included in this playlist so not sure what you mean. This playlist has 3 sections, Procedural in section 1, OOP in section 2, Advanced PHP in section 3 & final project.
@ezekielnizamani185
@ezekielnizamani185 Жыл бұрын
@@ProgramWithGio yes indeed it is included i meant creating other playlist for only oop would be better if someone want learn just oop he\she will just go to that playlist and learn oop.
@ProgramWithGio
@ProgramWithGio Жыл бұрын
@@ezekielnizamani185 video can only be part of one series on KZbin so I can't put it in another playlist. That's why I have outline repo which lists all videos in order & sections so it's easy to find. Also thumbnail colors are different for each section so it's easy to know which section you are watching. They are also numbered in thumbnail top left corner, this video for example is 2.7 - section 2, episode 7.
@ezekielnizamani185
@ezekielnizamani185 Жыл бұрын
@@ProgramWithGio ok thanks bro i will look repo
@ovidiublaga1
@ovidiublaga1 2 жыл бұрын
If you make a symfony course, I would totally buy it
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌
@migueldemaria3830
@migueldemaria3830 3 жыл бұрын
Any thoughts on the idea of Singleton classes being an Anti-Pattern? Thanks for the great instruction, Gio!
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
You're welcome, Miguel. Yes, it has become more of an anti-pattern recently, dependency injection is the "right" way which I'll cover in this course. I personally never liked singletons, it introduces unnecessary complexity, tight coupling & most of the time it is misused & overused. So I would stay away from it unless you have a really good usecase.
@migueldemaria3830
@migueldemaria3830 3 жыл бұрын
@@ProgramWithGio thanks for explaining that. I look forward to learning about the dependency injection.
@prashantgupta1940
@prashantgupta1940 7 ай бұрын
Great course packed with a lot of information. Just want to know from Gio and other people taking it, is required to code along with every lecture as I am a beginner to PHP and come from the background of Python so many concepts are new to me and if I am coding along one lecture take up to 30-40 minutes. If not what is the best way to do it.TIA
@ProgramWithGio
@ProgramWithGio 6 ай бұрын
Its not required but its highly recommended. Its ok to take that long for a video/lecture, that way you are retaining most of the information by practicing. Keep it up
@prashantgupta1940
@prashantgupta1940 6 ай бұрын
@@ProgramWithGio Thanks Gio great work with the video lecture really appreciate all the effort you have been putting in it.
@CarlosOrtiz-sz2pp
@CarlosOrtiz-sz2pp 2 жыл бұрын
Thank you very much
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome 👍
@dawid_dahl
@dawid_dahl 3 жыл бұрын
If one is using a class like your Format example with only static methods, could one just as well just make an associative array called Format with the an appropriate name like “amount” as key, and a function as value? Just a matter of taste, or is some better than the other for some kind of reason?
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Sure but I prefer to work with classes & methods. It would be harder to read to call a function on an array
@AMoktar
@AMoktar Жыл бұрын
Thanks bro for this great effort . Can you please prefix videos with counting number , that will be great too . Thanks anyway ❤
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Can't do that unfortunately, lesson numbers are in thumbnails & in description and there is also a full outline repo (link in description) that lists all videos in order. Numbering videos in titles hurts their visibility.
@aymanelash2685
@aymanelash2685 Жыл бұрын
can you please give a real example on why we should user PRIVATE then making setters and getters instead of just using PUBLIC ?
@aymanelash2685
@aymanelash2685 Жыл бұрын
and this course is absolute masterpiece 💌
@ProgramWithGio
@ProgramWithGio Жыл бұрын
If you set properties to be public you are giving ability to directly change the state of your object to anyone outside of that class. With PHP 8.1 you can use readonly properties and have them public or keep them private/protected with getters.
@javierquiroga6774
@javierquiroga6774 Жыл бұрын
It would be nice to see how to chain php non-static methods with a static method
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Not sure I understand, can you give an example? Do you mean something like Example::foo()->bar() ?
@javierquiroga6774
@javierquiroga6774 Жыл бұрын
@@ProgramWithGio yep!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
@@javierquiroga6774 In that example foo is static & bar is non static
@Zubbee
@Zubbee 2 жыл бұрын
Thanks a lot for this. Finished and I believe I'm following. Just that I wish I had some real project where I could be trying/applying this. Cause for now I'm just learning and learning. It's hard to test if I can recall and apply these. Maybe there's some code challenge or something online where I can test my knowledge. Is there? Great lesson. Thanks Gio
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad to hear that, thank you. I don't know any specific exercises but best way would be to just try & apply it to some small project. Even the project we worked in first section of the course, try & refactor it & play around with it with the new stuff that you learn.
@Zubbee
@Zubbee 2 жыл бұрын
@@ProgramWithGioSounds like a good idea. I'll probably goof but it'll be helpful. Thanks Gio
@EuegenTv
@EuegenTv 2 жыл бұрын
Why I don't speak English better :( So good content in these videos ! Author you are really pretty good!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 💙
@codinginstitution1742
@codinginstitution1742 Жыл бұрын
Wondeful
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you
@NoobieProgrammer
@NoobieProgrammer 21 күн бұрын
I Have a doubt, Iam sharing my container instance using singleton pattern, is this right way or any other good methods?
@ProgramWithGio
@ProgramWithGio 21 күн бұрын
you could share it that way or you could put it on the app instance & access it from the app object
@NoobieProgrammer
@NoobieProgrammer 18 күн бұрын
@@ProgramWithGio App Instance is singleton or not
@Armando-px8hi
@Armando-px8hi Жыл бұрын
Gio sorry for anxiety, but can you please explain what I am doing wrong that I am getting this error Fatal error: Uncaught Error: Class "App\PaymentGateway\Paddle\Transactions" not found in C:\xampp\htdocs\oop\src\public\index.php:9 Stack trace: #0 {main} thrown in C:\xampp\htdocs\oop\src\public\index.php on line 9. My index.php is located in oop/src/public and my Transactions.php is located in oop/src/app/PaymentGateway/Paddle.Also here is the code in index.php require_once __DIR__ . '/../../vendor/autoload.php'; use App\PaymentGateway\Paddle\Transactions; $transaction = new Transactions(); echo $transaction::class;
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Can you share source for your Transactions.php? You can DM me on Twitter also and send me the screenshots, I can help troubleshoot.
@Armando-px8hi
@Armando-px8hi Жыл бұрын
@@ProgramWithGio I just send it my friend.
PHP - Encapsulation & Abstraction -  Full PHP 8 Tutorial
15:23
Program With Gio
Рет қаралды 31 М.
PHP Traits - How They Work & Drawbacks - Full PHP 8 Tutorial
31:41
Program With Gio
Рет қаралды 32 М.
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,4 МЛН
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 99 МЛН
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 4,1 МЛН
PHP Enums With Practical Examples - Full PHP 8 Tutorial
28:13
Program With Gio
Рет қаралды 25 М.
No, Einstein Didn’t Solve the Biggest Problem in Physics
8:04
Sabine Hossenfelder
Рет қаралды 273 М.
What Are PHP Magic Methods & How They Work - Full PHP 8 Tutorial
16:55
Program With Gio
Рет қаралды 29 М.
What Is Late Static Binding & How It Works In PHP - Full PHP 8 Tutorial
9:58
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,4 МЛН