What Are PHP Magic Methods & How They Work - Full PHP 8 Tutorial

  Рет қаралды 31,384

Program With Gio

Program With Gio

Күн бұрын

Пікірлер: 106
@wesammohammed1819
@wesammohammed1819 16 күн бұрын
"Thank you, my teacher Gio! Your passion for teaching inspires me to keep pushing forward."
@ProgramWithGio
@ProgramWithGio 16 күн бұрын
You're welcome
@federicobau8651
@federicobau8651 3 жыл бұрын
Best php magic method tutorial and best php course, better than paid bootcamps
@ינוןאלבז-כ1ז
@ינוןאלבז-כ1ז 2 жыл бұрын
This channel is the channel with the most value on KZbin, and on the web in general, by far
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 💙
@chenting71
@chenting71 2 жыл бұрын
A real road map to learn PHP. Sometimes, I have to spend good time offline to grasp and have chewed understanding of your tutorial. Which is expected. Greatgreat guidance!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad to hear, thank you 💙
@non9831
@non9831 2 жыл бұрын
This is how to make php great again, very good content
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 💙
@ינוןאלבז-כ1ז
@ינוןאלבז-כ1ז 2 жыл бұрын
Exact!
@bewildstudio
@bewildstudio Жыл бұрын
Super professional video tuts... so many details...even mid devs find a lot of interesting things. What a job has been done! Thank you! Definetly donate, if i find a job)
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you, glad you find videos useful 🙌
@sahbikardi7801
@sahbikardi7801 3 жыл бұрын
man your vidoes make everything clear thank you so much for this great content.
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Glad to hear that, you're welcome & thank you 🙏
@tolebiGamingTime
@tolebiGamingTime 3 ай бұрын
Good lesson
@ProgramWithGio
@ProgramWithGio 3 ай бұрын
Thanks for watching
@karolzamojcin1886
@karolzamojcin1886 Жыл бұрын
Man you keep on rockin! Starting at 00:00 I must admit that I thought that this video is going to be of no interest to me. I was wrong. __invoke & __toString are most interesting to me. Where __call & __callStatic are not short after. Wonderful, thank you Gio 🏆
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Happy to hear, thank you
@z3ko
@z3ko 3 жыл бұрын
7 pages of notes on this video (with code examples) :D You are on another level with you knowledge and ability to clarify compared to all of the other sources.
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
That's awesome :). Thank you so much 🙏
@Vitalii-m6r
@Vitalii-m6r Жыл бұрын
There are plenty of magic methods. Thanks for this tutorial!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're very welcome
@tomekmacccc11
@tomekmacccc11 Жыл бұрын
Gamarjoba, Gio! Great tutorial! Thank you for your hard work! TM from PL :-)
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Gamarjoba 👋. Thank you 🙏
@saugmaddox349
@saugmaddox349 3 жыл бұрын
Sir also include exception handling in this oop tutorial. Your tutorials make doubts crystal clear
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Definitely, exceptions lesson coming up soon
@faramarztayyari3734
@faramarztayyari3734 3 жыл бұрын
Thank you for this awesome tutorial
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
You're welcome. Thank you!
@Armando-px8hi
@Armando-px8hi Жыл бұрын
The best of the best!)
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you
@CarlosOrtiz-sz2pp
@CarlosOrtiz-sz2pp 2 жыл бұрын
Magic methods are very interesting lesson. thank you
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad you like them. Thank you
@Zubbee
@Zubbee 2 жыл бұрын
Watched thrice already. Each time things were clearer but I still didn't get some magic methods (__call and __callStatic). But you did say not to worry if we don't get it as of now. Thanks alot Gio
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You'll see more examples of call & call static in third section and will understand it more 👍
@karam0101
@karam0101 2 жыл бұрын
Another great tutorial. Thank you for sharing all these concepts
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌
@AbdouAbdou-hu9un
@AbdouAbdou-hu9un Жыл бұрын
thank you @Gio, in 14:51 you said you needed class with one method than why didn't you just declare a function instead ?
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You could, it's just if you have a class with just a single method you might like the invokable option better, it comes down to preference, nothing wrong with having a single method in a class
@josephnduati1214
@josephnduati1214 Жыл бұрын
Thanks a Ton!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're welcome
@baptistedara8026
@baptistedara8026 2 жыл бұрын
you are amazing dude thank you
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
No, you're amazing, thank you 🙌
@ilya_123__
@ilya_123__ Жыл бұрын
thank you!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You're welcome!
@memack101
@memack101 2 жыл бұрын
Thank you.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome!
@abduabdu7404
@abduabdu7404 2 ай бұрын
Hello Gio, in the examples of using the call() method why didn't you use the splat operator and instead used call_user_func_array(), is there any advanced reason for that, like a better performance from call_user_func_array()?
@ProgramWithGio
@ProgramWithGio 2 ай бұрын
Probably an old habit. Yes the splat operator would work as well & is actually probably faster than using the call_user_func_array
@abduabdu7404
@abduabdu7404 2 ай бұрын
@@ProgramWithGio Thank you for your response, its not only the course that is great but also you as a person for not being arrogant and helping others learn what is best to learn and updating the course two years later❤
@МаксимСлободянюк-н9о
@МаксимСлободянюк-н9о 3 жыл бұрын
Thank you SO MUCH!!!
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
You're welcome!
@kvanca2330
@kvanca2330 2 жыл бұрын
Amazing series thank you. After years with php still something to learn. Can you deep dive to laravel to show those magic methods in action?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌. I'll be doing more Laravel content in 2023
@kvanca2330
@kvanca2330 2 жыл бұрын
@@ProgramWithGio Glad to here that. Wish you best of luck
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@kvanca2330 thank you 🙌
@vkmishra.singer
@vkmishra.singer 2 жыл бұрын
Great!! I request you to please create the course for laravel and explain whatever OOPS concept is used there.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you. I'll have more laravel content once I finish this series
@vkmishra.singer
@vkmishra.singer 2 жыл бұрын
@@ProgramWithGio Thanks. I will be waiting for new awesome laravel series.
@shaikhalamin23
@shaikhalamin23 2 жыл бұрын
Thanks for your great tutorial. I request to you that can you please make your playback little slow.? sometimes I really get over whelmed by your speaking speed.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thanks for the feedback. I know about that and improved on it in later videos. You can also adjust the speed on KZbin and slow it down for those that are too fast
@lxbdr
@lxbdr 2 жыл бұрын
Thanks for the great series! Do I get it right that the __invoke pattern can be used to make a function available to a class via DI so it is a explicit dependency instead of relying on a regular function to be present?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Invoke just makes class be called as a function. Makes something like this possible: (new A())()
@SaiyanJin85
@SaiyanJin85 Жыл бұрын
Thanks for the great video! I think using the magic methods should be done when someone builds a framework or something like that. I see no reason to use the_get or _set_ for example on a project that has business logic, imagine unsetting or setting properties on the fly...
@ProgramWithGio
@ProgramWithGio Жыл бұрын
It depends, it can be useful in non framework/library code as well. Although, I agree with having less magic in userland
@SaiyanJin85
@SaiyanJin85 Жыл бұрын
@@ProgramWithGio Thanks for the reply and your videos! Great job!
@Em1lka_
@Em1lka_ Жыл бұрын
Hi Gio, could you recommend any plugins for php storm? Something for php/laravel
@ProgramWithGio
@ProgramWithGio Жыл бұрын
I don't really use any plugins, only when I have specific needs but for the most part phpstorm is enough
@DAG_r8
@DAG_r8 2 жыл бұрын
Hi Gio, thank you for this , What is the advantage of using __invoke vs calling a function from the constructor ?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
It's ideal if you don't execute any methods in constructor because then when you inject that class as a dependency anywhere else if you use autowiring DI it will be executing it every time and can affect performance depending on what the method is or worse perform some updates again depending on what that method does.
@massimoramaj3233
@massimoramaj3233 Жыл бұрын
Hey Gio ,what's the difference between accessing properties as $this->$property and as $this->property , cuz both ways work!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
$this->property accesses the value of the property defined in the class, $this->$property access the value of a property whose name comes from the value of variable $property. Its variable variables, we covered that in first section.
@saravanasai2391
@saravanasai2391 2 жыл бұрын
Sir really i have watching this video 10 time ...i cant remember this lots of information...how can we practice to get a better more understanding practicaly
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
The best thing to do is try it out on a project. Build a todo list or even refactor the exercise from the first section and try to apply magic methods to it.
@keremardicli4013
@keremardicli4013 Жыл бұрын
Magic methods are indeed magic. It is hard to wrap my head around.
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Heh, yea it can be tricky at times
@bakre_dev8728
@bakre_dev8728 Жыл бұрын
Thanx 🎉
@ProgramWithGio
@ProgramWithGio Жыл бұрын
No problem
@NedumEze
@NedumEze 2 жыл бұрын
Sorry, Gio, why do we have "return $this->$name"? I thought it should be the conventional "$this->name". Or have I missed something?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
It's called variable variables. We covered that in the first section. $this->name would return the value of name property where $this->$name returns the value of the property of whatever the $name evaluates to.
@NedumEze
@NedumEze 2 жыл бұрын
@@ProgramWithGio Ah! Thanks. I didn't read it that way.
@أحمدكلش-ض3ع
@أحمدكلش-ض3ع 2 жыл бұрын
i hop you start laravel course before i finish this course
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
I hope too :)
@dawid_dahl
@dawid_dahl 3 жыл бұрын
Is there any reason why one would do a single responsibility class with the __invoke magic method, when one could just maybe write a simple function? 🤔
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Mostly it's preference. Usually used got single action controllers or when you have action classes with single methods. You can also pass an object of class as callable/closure when it is invokable, though I haven't tried this in awhile so you would have to test it
@chenting71
@chenting71 2 жыл бұрын
By the way, I understand those magic methods as "Event Trigger" provided by PHP, when operating on $object :D
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
👍
@AJ-Pixelyze
@AJ-Pixelyze 3 жыл бұрын
Hey, I wonder if you could make a video of how to use PHP with javascript. I know how to use JS but when it comes to PHP and JS working together with HTML, I have no clue how to connect them when it comes to DOM to add some JS
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
The project that we'll work on at the end of the series will have some JavaScript so that might be helpful.
@hancysp
@hancysp 2 жыл бұрын
volim
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
💙💙
@sergeisurin2963
@sergeisurin2963 Жыл бұрын
👍🙏
@ProgramWithGio
@ProgramWithGio Жыл бұрын
🙏
@FGj-xj7rd
@FGj-xj7rd 2 жыл бұрын
There is nothing magical about these methods 👎
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
That's what it's called 🙂
@FGj-xj7rd
@FGj-xj7rd 2 жыл бұрын
@@ProgramWithGio I know 🤷🏻‍♂️
@aiphan3126
@aiphan3126 2 жыл бұрын
public function __call(string $name, array $arguments) { if (method_exists($this, $name)){ $this->$name(...$arguments); # instead of call_user_func_array([$this, $name], $arguments); } } Hi sir, I found out this, it also worked. Are they different ?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
That would work as well, in this example they are pretty much the same, might be some differences in terms of performance but I have not benchmarked it.
@aerohcss
@aerohcss 3 ай бұрын
Hey, Gio, thanks for your hard work, I love course very much so far! Just wanted to add that code on kzbin.info/www/bejne/pHTbn62gbZijpbM will cause the error if you comment out the line $invoice->amount = 35; The Error is "Typed property app\Invoice::$data must not be accessed before initialization". I guess the solution is just setting to $data property default value []
@aerohcss
@aerohcss 3 ай бұрын
I just watched video further, so nevermind 😀
@ProgramWithGio
@ProgramWithGio 3 ай бұрын
Hey, thank you. Yea the error would make sense if you comment out that part :)
What Is Late Static Binding & How It Works In PHP - Full PHP 8 Tutorial
9:58
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
PHP Traits - How They Work & Drawbacks - Full PHP 8 Tutorial
31:41
Program With Gio
Рет қаралды 34 М.
PHP Abstract Classes & Methods - Full PHP 8 Tutorial
9:36
Program With Gio
Рет қаралды 27 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН