PHP - Object Cloning & Clone Magic Method - Full PHP 8 Tutorial

preview_player
Показать описание
In this lesson, you will learn how to clone objects & the magic method that gets called after an object has been cloned in PHP.

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
THANK YOU!

LESSON 2.18

RESOURCES
Рекомендации по теме
Комментарии
Автор

I wake up at 4:30 AM every day and spend the first 3 hours of my day watching this playlist. Can't wait to see how I'll do with the exercise project!

Sasha-libn
Автор

Love this playlist. Even though I use PHP day in day out, this is a great refresher and provides some of the best explanation / examples I've ever seen. Plus gain some insight on aspects of PHP I don't use, but might find a use for.

thisbridgehascables
Автор

I'm glad i found your channel, thank you for your efforts

aleksandrkanygin
Автор

Bro, Initially I had trouble following the course becoz i was moaning there was no source code. But i am going through the Part 2 all over again and this time entering the code, it really made sense and i was understanding things better. Thank you so much bro.

truthteachers
Автор

I really do like your videos Gio, that's why I really do like and comment. It's the least I can do for such great content.

Zubbee
Автор

Great content and very well explained.

federicobau
Автор

Nice work! Clear and objective explanation

ryanw.fonseca
Автор

3:20, Can't we just use self::__construct(), to call the constructor and generate new unique ID? i did it and it works, is it a bad practice or something?

Śmiechoteka
Автор

Clear explanation Thanks for the video

ינוןאלבז-כז
Автор

Hello Gio, thank you for the great explanation on the cloning of objects topic. What would be a practical scenario where we would implement/use this oop feature?

bogdanmarian
Автор

Thanks for the video, Gio!

0:51 I wonder why the dumped objects have these out-of-order IDs: #3, #2 and then #4. I ran the same code on my machine and got #1, #2 and #3. How can that be explained?

ryanford
Автор

Hi Gio, what do you mean exactly by shallow copy of an object?

rosarioveneruso
Автор

Is it correct to say that the 'clone' keyword in PHP is an implementation of the Prototype pattern?

Vitalii-mr
Автор

Hi Gio. I like your contents. Do you have video tutorials of a real web project? Are you planning doing that and share it on the youtube? Thank you

andrepedrosa
Автор

I have a question that is indeed a bit to understand the key value of frameworks and dependency packages. In these I more often find self() instead of the static() that you mention and I understand the difference but guess it might be the same in this case to use the one or the other.

In many above constallations the result is:

class A {
public function adapter() {
$instance = B::create();
}

class B {
public static function create() {
return C::create(new self());
}

class C {
public function __construct($value)
{
$this->value = $value;
}
public static function create($value):self {
return new self($value);
}

For me this is confusing and not readable. I guess the result is that I have $instance that is an object of class C and has access to the object of class B through $instance-value. Am I right? Why that complicated?? For me object orientation is to get more clearity to the code but in a framework and similar it for me only results in mad code chaos. I understand what the method of A shall do but it runs through two other classes that have nothing to do with it to achieve it. I simply don't understand why I should include such a mess into my code.

Could you please tell me: If I really understand what the framework/package does, do you think it is still better to rely on the framework/package or is it better to use my own code that simply returns the exactly same result but more readable and/or faster with less extra loops? I more and more come to the point that it only makes sense to use a framework if you ignore what it does in the background and just rely on the results it offers. For me I would always want to either to understand all the third party code or varify every result coming from that code. I guess that is no effective coding....

lairotuT-Tutorial
Автор

Just to mention that you can use __FUNCTION__ to print name of the function :)

bogdansipka
visit shbcf.ru