Creating classes, properties, methods - OOP in PHP | Part 1

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • In this video, we are going to create a simple class in PHP.
    We will add public and private properties and methods.
    We will create an instance from the class and learn how to set and get properties.
    We will understand what is encapsulation.
    Follow me on social media:
    / thecodeholic
    / thecodeholic
    github.com/the...

КОМЕНТАРІ • 37

  • @hassanhafiz44
    @hassanhafiz44 3 роки тому +3

    I just completed Bs CS (Hons) and I always think which tutor to prefer to my friends and young students. I have found one. I'm also watching these videos. I hated PHP but as a PHP developer. I have started to understand it through your videos. Thanks Sir.

  • @secret_one
    @secret_one 4 роки тому +7

    Thank you, I have learnt more about OOP in your first 2 videos than I have in many "whole" courses/books on the subject.
    I am not sure what it is that is different from the others, your teaching method or your explanations. Whatever it is, it is working. Thank you again.
    Now to continue with the rest of the videos.

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

      Huge thanks buddy for that comment
      It means a lot.

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

      I want to post your comment on my twitter. Are you ok with that?

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

      @@TheCodeholic Yes of course, please go ahead.

  • @oraki13
    @oraki13 4 роки тому +3

    Thank you for these detailed tutorial. I have searched for a long time for some basic tutorial and finally found one with yours. Thanks again for your efforts and keep going with those :))

  • @jahir_valverde
    @jahir_valverde 3 роки тому +2

    Thanks for the free education videos, really appreciate it

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

    Thanks dude! Love your Admin template also. Amazing!

  • @rpralica
    @rpralica 11 місяців тому

    Great explanations espetialy for getters and settres thank You

  • @catalinbiru8396
    @catalinbiru8396 3 роки тому +2

    Thank you very much for this!

  • @codingtostopprocrastinatio9748

    Very good tutorial !

  • @Lyrik-Klinge
    @Lyrik-Klinge 2 роки тому

    very good explaination, THANKS!

  • @kenjohnsiosan9707
    @kenjohnsiosan9707 Рік тому +1

    Thank you sir.

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

    Very good class! Congratulations!

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

    Thank You for the video

  • @ilya_123__
    @ilya_123__ 6 місяців тому

    Thank you!

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

    Hi thank you for those tutorials they are awesome. how do you set up the terminal on the right which updates after changes and provides outputs. Thanks.

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

      PHP Storm has possibility to move windows around.
      The terminal does not automatically executes the code after changes. If it seems like this, probably it is because of video editing...
      I run the code manually in terminal.
      Thank you.

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

      that makes sense . Thanks.

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

    thank you! Could you add comments/ annotations to the code for e.g. where you have used an instance etc.

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

    thank you

  • @QQ-wv3gz
    @QQ-wv3gz 3 роки тому +1

    Please use dark theme editor...

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

    hello, nice tutorial but i didn't get an error when trying to access the private property of the class as you said, and i am wondering why

  • @foreign-livingtheamericand8782

    hello, how do you echo multiple class function?

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

    I have a question,
    why we need to set and get? I tried to put return on setYear
    public function setYear($year){
    return $this->year = $year;
    }
    public function getYear(){
    return $this->year;
    }
    echo $myCar->Setyear(2010);
    echo $myCar->getYear();
    output: 20102010
    why not exactly put return on the setYear? and why we need getYear and put the return thier? Thanks.

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

      Purpose of the setters and getters is to run some logic before actually assign or return value.
      Setter accepts argument and saves the value in a property of the class.
      Getter returns the value of the property.
      If year must always be greater than 2000 you can write an if statement in setter and don't assign value if it is NOT greater than 2000.
      I hope this makes sense...

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

      @@TheCodeholic Thank you so much. after this course oop , I will watch your yii framework.

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

    how to the result and the desktop name in terminal have the newline?

  • @ThichThiHoc
    @ThichThiHoc Рік тому

    Thanks you very much. How can I get the source code of this course, please?

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

    $mycar->setYear(year:2010) , I don't know how this line worked. Can anybody explain ?
    My opinion is it should be $mycar->setYear(2010) or $mycar->setYear("year:2010")

    • @TheCodeholic
      @TheCodeholic  4 роки тому +3

      I can understand why you are confused. There is actually written $mycar->setYear(2010) .
      This will not work in PHP "$mycar->setYear(year:2010)", but PHPStorm understands function argument names and displays them so that if function has 2 arguments or more and you don't remember which is first and which is second it will show the name of the argument when you want to execute the function.
      I hope this clarifies the case.

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

      @@TheCodeholic I had the same problem. Thank you very much for your help.

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

    Thank you very much for this!