PHP OOP Full Course

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 173

  • @howtocodewell
    @howtocodewell  4 роки тому +5

    Join our Discord server howtocodewell.net/discord and ask coding questions in the coding-help channel

    • @BillClinton228
      @BillClinton228 4 роки тому

      Thank you so much for this tutorial. You have made life much easier.

  • @danielonibokun8351
    @danielonibokun8351 5 років тому +16

    Man you have no idea how clearly i am able to understand you compared to anyone else man. 101/100. Thank you!

  • @winstonmcquoid9336
    @winstonmcquoid9336 5 років тому +11

    Awesome video. I've been out of the PHP loop for a few years now and this was an excellent refresher and learning experience. Thank you!

  • @ellbrant
    @ellbrant 5 років тому +6

    Thank you! I've been reading/researching OOP and your video put it all together for me. I especially liked that you showed the related errors, just being familiar with those will make created solid code easier. Can't wait to check out your other videos.

    • @howtocodewell
      @howtocodewell  5 років тому +2

      I'm glad you are finding these videos helpful. I've been live coding a PHP OO applications on Twitch and archiving them here on UA-cam.

  • @nicollado1904
    @nicollado1904 3 роки тому +1

    Thank you for this. I am not a native English speaker yet I find this tutorial quite comprehensive. This video saves my day.

  • @slapmyfunkybass
    @slapmyfunkybass 5 років тому +4

    Thanks for the video. Coming from a c# background I needed a refresher on php’s take on oop. Just one point, static declarations are simply shared values between different instances of the class. So you could in your constructor reference the static property, (let’s say it’s called add with default value 0), with add++. Each time an instance of that class is created, it will remember the value. You can’t do this with normal properties as they always default to their original value. Maybe php is different, but I wouldn’t have thought so.

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Yes that is a great point. I'm planning to do something similar to this when updating the invoice totals per invoice item.

  • @SkyrimBeast
    @SkyrimBeast 4 роки тому +1

    Many thanks for the video Peter. It's always good for me to watch courses like this as a kind of refresher. I'm the type of developer that tends to forget stuff I haven't had to use over a period of time.

    • @howtocodewell
      @howtocodewell  4 роки тому +1

      Me too. I an always having to re trace my steps. I'm glad you liked it

  • @DiscipleW
    @DiscipleW 5 років тому +2

    Very good tutorials, thanks !
    As the people below are saying your talking very clear and even in 1.5 speed it's like a breez.

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Thank you very much. Please let me know if you have any suggestions for future videos

  • @musiclovers8488
    @musiclovers8488 4 роки тому +2

    You are awesome dude!!
    I am from India and my English is not too good but how was you teaching that was totally awesome !!
    And the way of teaching is also too good !!
    Thanks a lot

    • @howtocodewell
      @howtocodewell  4 роки тому +1

      That's great to hear. Thank you :)

    • @musiclovers8488
      @musiclovers8488 4 роки тому +1

      You are welcome!!
      Can you upload video on one more topic !!
      How can we implement all these functions and how can we use in any real project?

    • @howtocodewell
      @howtocodewell  4 роки тому

      I'm working on something like that on Twitch twitch.tv/howtocodewell

  • @jaymillena1053
    @jaymillena1053 5 років тому +3

    Thank you for this. This made correction to some of my false theory.

    • @howtocodewell
      @howtocodewell  5 років тому

      I'm glad you found the course useful

  • @majedhk5460
    @majedhk5460 5 років тому +3

    10/10 tutorials Thank you sir *respects*

  • @sale7680
    @sale7680 2 роки тому

    Bravo best teaching ever 🙌

  • @shishupalsinhsodha5397
    @shishupalsinhsodha5397 3 роки тому +1

    I found this very useful Tutorial

  • @br31woodlands69
    @br31woodlands69 4 роки тому +1

    This is really a wonderful tutorial. Thank you much!

  • @ahmaddawood9691
    @ahmaddawood9691 4 роки тому +1

    Excellent tutorial , Thanks a lot

  • @ruans.p.5323
    @ruans.p.5323 2 роки тому

    Good job, thank you. Subscribed.

  • @mackynyxz
    @mackynyxz 4 роки тому +1

    Nice tutorial! it refreshes me a lot!.

  • @mostafahsv3360
    @mostafahsv3360 5 років тому +3

    Thanks for this great video. I could understand every word as your style is smooth and simple. I just wanted to know what kind of code editor you use because I see it's great. Thanks in advance.

  • @sharmashivanand
    @sharmashivanand 4 роки тому

    Have been coding php for several years but it's pure joy to revisit fundamentals especially demonstrated so well. Do you also have tots on singleton, abstract, final classes?

    • @howtocodewell
      @howtocodewell  4 роки тому

      Not yet by they are on my list for future tutorials

  • @mistacodeTV
    @mistacodeTV 4 роки тому +1

    Awesome video.

  • @baref0ot455
    @baref0ot455 5 років тому +2

    Is there such a thing as an association relationship in PHP? Such that a classB can contain an instance of classA as a property inside of classB?
    What you would call containment in other OO languages such as Java or C#.
    If not, how could you accomplish this is PHP?
    Example:
    class A{
    // properties
    public string $name = "";
    }// end class A
    class B{
    // properties
    public $obj = new A();
    }// end class B

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Hey Baref0ot yes you could use a factory pattern for this or a singleton.
      These are great questions. May I invite you to our Discord server where you can ask these types of questions to our growing community. You can also format code far better in Discord than UA-cam comments
      howtocodewell.net/discord

  • @dibbyo456
    @dibbyo456 3 роки тому +1

    Thank you for using CLI.

    • @howtocodewell
      @howtocodewell  3 роки тому +1

      I find that it’s the best way to do it.

  • @kensleylewis
    @kensleylewis 5 років тому +1

    That last part was tricky, because it feels like it shoul of been parent not self, sense it was defined in the parent class, but then returned in the extended class.

  • @tiffanyurigirlsg3185
    @tiffanyurigirlsg3185 5 років тому +5

    May I know the code editor he is using in this video? Thank you

  • @ramam8582
    @ramam8582 4 роки тому +1

    awesome video sir

  • @yorkshireplumbing
    @yorkshireplumbing 4 роки тому +1

    Why in the __set and __get methods did you use the syntax $this->$name instead of $this->name, like in the other examples?

  • @HolyErne
    @HolyErne 5 років тому +4

    Why you have to type $this -> $firstName = $firstName; I don't get this part? $firstName is equal to it self?

    • @nemanjavukmirovic2262
      @nemanjavukmirovic2262 5 років тому +2

      i dont understand that too, i just accepted it is this way to write...i guess thats how php know its a definition belonging to classes...but good question tho

    • @cristianenache8715
      @cristianenache8715 5 років тому +6

      He doesn't actually explain a lot of what he's typing. $this->firstname refers to the public property firstName of the Person object (note there's only one dollar sign, at the beginning of this). And the $firstName on the right side of the equals sign is the parameter that the function receives, when you instantiate the class. So the constructor function receives a value for $firstName, and stores it in the public property with the same name.
      $this->firstName = $firstName;

    • @howtocodewell
      @howtocodewell  5 років тому +3

      Thank you for jumping in and answering this. You are correct.
      I think I will need to do a refresher course or something to explain this parts in more detail.

    • @perianka
      @perianka 4 роки тому

      @@howtocodewell please do :) we would apreciatte that

  • @syaleni2
    @syaleni2 5 років тому +1

    A question that popped to my head is that, the __construct method is a public function. Nevertheless, when the Person class was extended by the Employee class, in the __construct method for Employee, the __construct method of Person class was called statically. Shouldn't that cause an error?

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Yes I can see what you mean. This how the parent class is called and it's not done statically. You've picked on a quirk of PHP 😃

  • @rimantasdanilevicius6754
    @rimantasdanilevicius6754 5 років тому +4

    Hi, I am did not understood one part: 1:04:41. You have 2 classes, none of classes have static method.
    When you want get smth Class usually we use echo $object->parameter of metchod, and this Employee:: calls static parameters or methods, is it right? I get lost here, why you use this syntax Emplyee::. is it because it is constant?

    • @howtocodewell
      @howtocodewell  5 років тому +3

      Excellent question. Here I am accessing the constant value from outside of the class. To do this you use CLASS_NAME:: CONSTANT
      To do this within the class you would use self::CONSTANT
      In my next PHP OOP course I will explain this better.
      This was a great question and I will add it to the 10k subscribe AMA.
      Thank you

  • @skrezwan12
    @skrezwan12 5 років тому +3

    Your "upps" are so cute :3

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Hi Sk, I'm unsure what you mean by my 'upps' - But I will take it as a compliment 😊👍😃

    • @skrezwan12
      @skrezwan12 5 років тому +1

      @@howtocodewell "That's you making mistakes ""whoops"" " !!! :v (y) btw, carry on.

    • @howtocodewell
      @howtocodewell  5 років тому +2

      I totally get that now! Other commenters have mentioned it too. There should be a Whoops montage video of all of my "Upps, Whoops and Opps" hahaha

    • @navjotsingh2251
      @navjotsingh2251 5 років тому +1

      Peter Fisher make this haha it’ll be a laugh.

    • @maozedong5311
      @maozedong5311 4 роки тому

      @@howtocodewell right

  • @nemanjavukmirovic2262
    @nemanjavukmirovic2262 5 років тому +1

    good job sir!!!!!

  • @andreiindries1121
    @andreiindries1121 5 років тому +1

    Awesome tutorial. Can you please tell me the Color Theme you are using? Thank you.

    • @howtocodewell
      @howtocodewell  5 років тому +1

      I think this is Dracula. I prefer dark themes

    • @andreiindries1121
      @andreiindries1121 5 років тому

      @@howtocodewell Thank you. Yes I am using also Dark Themes. The one you used is very easy for the eyes. I will search for it in VS Code.

  • @jhonnatanromero9802
    @jhonnatanromero9802 5 років тому +1

    Is there anything specific you did to your terminal so it shows the PHP output as it is on your video?

  • @JNET_Reloaded
    @JNET_Reloaded 5 років тому +1

    So confusing can i have the example code you used please il figure it out by playing?

    • @howtocodewell
      @howtocodewell  5 років тому +1

      I don't think it's available but I will have a hunt on my old GitHub repos and check

  • @SpantikLab
    @SpantikLab 5 років тому +1

    Hi Nice video helped me alot.But i have a question in getter and setter method.My question is what is the advantage of using a member of class private if it is accessible with getter and setter instead make them all public??

    • @Peeetfish
      @Peeetfish 5 років тому +3

      Because you can control programaticly how this attribute is being manipulated. You could specify in your setter that only values greater than zero are allowed etc...if it's a public attribute you any function could access the attribute and do what ever it want with the data

    • @SpantikLab
      @SpantikLab 5 років тому +1

      @@Peeetfish Thanks Got it

  • @aprattdesign
    @aprattdesign 4 роки тому +1

    Why are we calling self::$bloodType instead of parent::$bloodType from the Employee extended class?

  • @perianka
    @perianka 4 роки тому +1

    What's the point of makin the variables private if you're gonna write the __$SET and __$GET methods anyway?? anybody is gonna be able to change them and get them
    I know that you can put certain parameters in the setter to prevent the user to set it's value to something invalid, but it's still pretty public to me

    • @howtocodewell
      @howtocodewell  4 роки тому +1

      Yes this was just for demonstration purposes. Magic methods are useful when you want to apply rules to a dynamic set of properties. I don't really use them much in my day to day work.

    • @perianka
      @perianka 4 роки тому +1

      @@howtocodewell oh ok thanks! by the way, I would love a more advanced tutorial on php :) like about OOP and things like that

    • @howtocodewell
      @howtocodewell  4 роки тому

      Hey Irina, Yeah I'm planning a PHP8 series in the future. Is there anything in particular you would like me to cover?

  • @sunnywaykar7175
    @sunnywaykar7175 4 роки тому

    Thank you sir..

  • @jeannoel8041
    @jeannoel8041 4 роки тому

    A nice video. Anyway, I had a question on how to pass a value in the setters method so that you can access the private properties. Do you have to pass that private property (argument) in the setters method so that it can be accessed outside the scope

  • @bernardchisumo4054
    @bernardchisumo4054 5 років тому

    Great Course

  • @Alexandre_amds
    @Alexandre_amds 5 років тому +1

    Parabéns

  • @just_the_job
    @just_the_job 3 роки тому

    Hi Peter, I was just wondering is there a follow on course on your channel that takes all this on to using interfaces, traits, abstraction and maybe the odd design pattern for a particular problem? Many thanks.

    • @howtocodewell
      @howtocodewell  3 роки тому

      Not yet but i will add it to my ideas list

    • @just_the_job
      @just_the_job 3 роки тому +1

      @@howtocodewell No worries Peter, thanks for the response. Your videos are greatly appreciated, there's not many youtubers that explain oop php in the detail you have, I feel I understand your explanations really well.

    • @howtocodewell
      @howtocodewell  3 роки тому

      Thank you Justin

  • @robtee7655
    @robtee7655 5 років тому +1

    Great Video. Like your accent. But Oriented != OrienTATed.

    • @howtocodewell
      @howtocodewell  5 років тому

      Haha 😀😀👍

    • @robtee7655
      @robtee7655 5 років тому

      @@howtocodewell Just trying to be helpful. :) The video is great!! Looked all over for something like this. Cheers and great job, again.

  • @matthewtang2148
    @matthewtang2148 4 роки тому

    may I know what tool you are using? Since @5:22, it showed the explanation of the errors that is easy to understand. Appreciate for your tutor :D !

  • @kinganthonyting7581
    @kinganthonyting7581 5 років тому +1

    Hi! Great tutorial! May I know what code editor are you using? Thanks!

    • @rutera24
      @rutera24 5 років тому +1

      I think a code editor use is IDE PhpStorm

    • @howtocodewell
      @howtocodewell  5 років тому

      Sorry for not getting back to you. Yes it's PHPStorm. One of my favourite coding IDE's

    • @howtocodewell
      @howtocodewell  5 років тому

      Thank you for answering this. You're totally correct. It's PHPStorm 😀

    • @kinganthonyting7581
      @kinganthonyting7581 5 років тому +2

      @@rutera24 Thank you so much!

    • @kinganthonyting7581
      @kinganthonyting7581 5 років тому

      @@howtocodewell It's okay. Thank you so much!

  • @armincal9834
    @armincal9834 5 років тому

    so i tried doing:
    $tom = new Person('Tom' , 'abc' , 'm');
    $tom -> SayHello();
    it gives me an error: too few arguments supplied for SayHello, expected 3 suplied 0.
    i thought the entire logic behind doing all this was to avoid having to re-write name,lastname,gender everytime?
    ok i found the answer myself, and im keeping this comment for anyone who might run ino the same problem in the future, when you define the SayHello function in your class, u gotta keep the argument list empty cz if u don't it will expect them even if the program doesn't really need them, what i did initially was this:
    SayHello($name ,$lastname , $gender)
    {
    //blah;
    }
    changed it to
    SayHello()
    {
    //blah;
    }
    and it works now xD

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Yeah that should be the case. The sayhello method shouldn't take any arguments. Perhaps something else is wrong.
      Feel free to post your code to pastebin and share the link so I can take a look

    • @armincal9834
      @armincal9834 5 років тому

      @@howtocodewell thank you very much for your quick answer, it was quicker than some paid UDEMY courses xD like i said, changing the arguments did work, imma like and subscribe to support ur channel xD

  • @Rilex037
    @Rilex037 5 років тому

    Construct is magic method? So I need another method to supply mana potions to it, thanks.

  • @mustafamahmud2977
    @mustafamahmud2977 5 років тому

    Done

  • @matthewtang2148
    @matthewtang2148 4 роки тому +1

    btw which time zone and when will you start the web chat on Friday?

    • @howtocodewell
      @howtocodewell  4 роки тому

      I'm not sure which we chat you mean?
      I live stream on Twitch Tuesday and Thursday morning's at 07:00 GMT and Sunday's at 14:30 GMT

    • @matthewtang2148
      @matthewtang2148 4 роки тому

      @@howtocodewell got it, thanks :D

  • @Desertbynight
    @Desertbynight 5 років тому +1

    Great tutorial! May I ask what is your code editor?

    • @howtocodewell
      @howtocodewell  5 років тому +2

      Sure. For PHP I use PHPStorm and for Python I use PyCharm

    • @twelve9046
      @twelve9046 5 років тому +1

      NetBeans

    • @howtocodewell
      @howtocodewell  5 років тому +1

      I used to use Netbeans i loved that editor. Have you considered PHPStorm?

    • @twelve9046
      @twelve9046 5 років тому +1

      @@howtocodewell nah, i hate subscription model of payment, i would like to pay once

    • @howtocodewell
      @howtocodewell  5 років тому

      Yes I know what you mean

  • @HarisPervaiz
    @HarisPervaiz 5 років тому +1

    Hello peter, thanks for the amazing tutorial, made my concepts clear however i have one question
    you called return self::$bloodType? wouldnt it be parent::$bloodType?
    i tested both and it outputs the same result. so whats the recommended option self or parent considering your example above

    • @subish20me
      @subish20me 2 роки тому +1

      self keyword is used to access the properties and methods which been declared as static whereas parent keyword is used to inherit properties/methods from parent class to child

  • @matt6805
    @matt6805 5 років тому

    I don't understand the point of using the magic __get() and __set() methods on the private class variables. In the previous lesson, he says that you use the private declaration to restrict variable access to within the class, which makes total sense. But then, he goes on to use these magic methods and completely overrides the reason for making them private in the first place! He's essentially made them public.
    I could see using these magic methods to remove the boilerplate code for writing getters and setters, but I don't understand why you're using them to expose private variables outside of the class. Am I missing a fundamental point here?

    • @howtocodewell
      @howtocodewell  5 років тому

      Hi Matt, no you're not missing anything and this is a great question. The magic methods all for access to the private properties. They are a quicker way to do it. Personally I don't like using them myself as they obscure the class definition.
      However they can be useful for setting defaults.
      Imagine you had serialised and unserialised an object and over time that objects class definition class has changed.
      In this case you may want to have a safety net to catch any properties that don't exist and set defaults.

  • @westfield90
    @westfield90 4 роки тому

    Just don’t know when to use the arrow sign? What does that mean?

    • @howtocodewell
      @howtocodewell  4 роки тому

      Do you mean this '->' as in $this->name; ?
      The arrow symbol here is a means to access the property or method from a class.
      If you join our Discord server we can help with code snippets.
      howtocodewell.net/discord/

    • @westfield90
      @westfield90 4 роки тому +1

      @@howtocodewell Thank you. Yeah I see that ' -> ' all the time in PHP and Laravel code and no idea what it means. I will definitely look into joining your site. Thank you

    • @westfield90
      @westfield90 4 роки тому +1

      @@howtocodewell BTW I have to say that I really love your clear articulate speaking and teaching style. Its very conducive to absorbing and learning this material. I would love to see you do more course and especially Laravel and React

    • @howtocodewell
      @howtocodewell  4 роки тому +1

      I have a new HTML/JS/CSS course coming out next week and on our Discord server I have asked which course I should do next. React is an option but I think it might end up being a PHP course due to the community responses

  • @martinkrivosija9685
    @martinkrivosija9685 3 роки тому +1

    Orientated != Oriented

    • @howtocodewell
      @howtocodewell  3 роки тому

      Can I ask where you spotted this mistake please?

    • @martinkrivosija9685
      @martinkrivosija9685 3 роки тому

      @@howtocodewell You say it at 0:09 :) Wonderful tutorial on OOP, one of the clearest explanations on youtube.

    • @umarhasnain7369
      @umarhasnain7369 3 роки тому +1

      @@martinkrivosija9685 If it is wonderful, that why are you pointing this small mistakes?
      Adore this tutorial, not abuse.

    • @martinkrivosija9685
      @martinkrivosija9685 3 роки тому +1

      @@umarhasnain7369 Erm okay. Didn't know pointing something out that he can improve on next time is "abuse". You need to relax. The creator clearly read it as constructive criticism.

  • @yagshaiq3
    @yagshaiq3 4 роки тому +1

    is this video complete?

    • @howtocodewell
      @howtocodewell  4 роки тому

      It's complete in the sense that I won't be adding to it but it's not complete in the sense of OOP.
      I'm currently developing a new course on OOP design patterns

  • @abhiraj3477
    @abhiraj3477 5 років тому +2

    Sir please provide php oop project

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Do you have anything in mind?

    • @skrezwan12
      @skrezwan12 5 років тому +1

      @@howtocodewell Ticket or Hotel booking system may be the best for the learner. You can consider my idea. Thanks :)

    • @howtocodewell
      @howtocodewell  5 років тому

      That's a good suggestion

    • @husseinmcheni3253
      @husseinmcheni3253 5 років тому +1

      the best is hotel booking system

    • @howtocodewell
      @howtocodewell  5 років тому

      Great suggestion

  • @mrbale1815
    @mrbale1815 4 роки тому +1

    You can create a new Employee with no $name , but still execute sayHello();

  • @ValentinDragan
    @ValentinDragan 5 років тому +1

    What's "oops" in you vocabulary? 32:20 38:56

    • @howtocodewell
      @howtocodewell  5 років тому

      That's me making mistakes whoops 😂

    • @ValentinDragan
      @ValentinDragan 5 років тому

      @@howtocodewell
      But there were none or so it seemed.

    • @howtocodewell
      @howtocodewell  5 років тому

      I think it's my English accent. When I miss type something or think that I've missed typed something I say oops out of habit.
      Perhaps I should do a 'oops' montage video hahaha

    • @ValentinDragan
      @ValentinDragan 5 років тому +1

      :))))

    • @howtocodewell
      @howtocodewell  5 років тому

      Perhaps someone from the community could do that hahha. I'm sure I have done this a bunch of times throughout my videos

  • @2wheeledgreco271
    @2wheeledgreco271 4 роки тому

    I got a little bit of a couch->corona

  • @attaulmustafamustafa8572
    @attaulmustafamustafa8572 5 років тому

    hello sir , i want to insert php script into mysql.. how i can do..

    • @howtocodewell
      @howtocodewell  4 роки тому

      I'm not sure I would recommend doing that. But I guess it would be stored as a string.

  • @saltplug4395
    @saltplug4395 4 роки тому +1

    Reeeeturn. Lol

    • @howtocodewell
      @howtocodewell  4 роки тому

      Pahahaha is that how I say it. I need someone to create me a blooper reel. hahaha

    • @saltplug4395
      @saltplug4395 4 роки тому +1

      @@howtocodewell This video may have saved my career though, for real. Thanks. (15 year functional coder)

    • @howtocodewell
      @howtocodewell  4 роки тому

      @@saltplug4395 Wow really. That is great to hear. All the best! :)

  • @adante407
    @adante407 5 років тому +1

    Great tutorial. But your text is too small for iPad, mobile etc, very hard to distinguish what you are typing, your theme doesn't help, that's why VS Code is so great for tutorials. I am not criticising, it looks a great tutorial, but unfortunately the syntax is just ineligible.

    • @howtocodewell
      @howtocodewell  5 років тому +2

      Thank you that is some great feedback. I will take this into account for future tutorials. I appreciate you bringing this to my attention

    • @adante407
      @adante407 5 років тому +1

      @@howtocodewell No probs, like I said I'm not criticising, on the contrary, its just unfortunate because it inhibits what looks a fantastic tutorial. Thanks. 👍

    • @howtocodewell
      @howtocodewell  5 років тому +1

      Thank you

    • @navjotsingh2251
      @navjotsingh2251 5 років тому

      Peter Fisher it all looks fine and well on my iPad Pro running iOS 13. Not to sure what problems Sean is facing...

  • @mistacodeTV
    @mistacodeTV 4 роки тому +1

    Awesome video.