PHP Object Oriented Programming (OOP): Classes (2/13)
Tagged on:                                                                                                                         

19 thoughts on “PHP Object Oriented Programming (OOP): Classes (2/13)

  • June 17, 2014 at 10:13 pm
    Permalink

    Is that Sublime? What's the theme? 😀 Thx

    Reply
  • June 18, 2014 at 2:43 am
    Permalink

    Alex 13 tutorials isnt enough

    Reply
  • June 18, 2014 at 6:53 pm
    Permalink

    For those who found the explanation about why the $person variable in the Person class was an error and that it needed to be $this instead, (I found it unclear the first time, the toning of when he said "Okay. Here we need to change this 'person' variable to 'this'. And basically what 'this' means is this current instance." was a little off so I had to re-watch it a few times to understand) here's a little more information about it.

    The reserved keyword $this is a reference to the current instance or object. Let's say you have this class:

    class Car
    {
        public $brand;
        public $model;

        public function identify()
        {
            return 'This is a ' . $this->brand . ' ' . $this->model;
        }
    }

    Which are instantiated like so:

    $car1 = new Car;
    $car1->brand = 'Opel';
    $car1->model = 'Astra';

    $car2 = new Car;
    $car2->brand = 'Nissan';
    $car2->model = 'Micra';

    Using the following line:

    echo $car1->identify();

    will result in:

    This is a Opel Astra

    $this is actually a reference to $car1 in this case.

    I hope this clears things up for the ones that didn't quite follow, like I did.

    # Edit, "Class" should in lowercase… oops.

    Reply
  • June 25, 2014 at 9:20 pm
    Permalink

    Nice for you to add subtitles. Makes me more understandable

    Reply
  • June 27, 2014 at 9:21 pm
    Permalink

    class person 
    public $name;
    public $age;

    $person = new person
    $person->zzname = 'John123';
    echo $person->zzname;

    Returns: John123

    What is the point of declaring $name in the class, if we can assign any property to the person object via zzname?

    Reply
  • August 7, 2014 at 2:09 pm
    Permalink

    what editor so u use, new to mac. for the php of course

    Reply
  • October 6, 2014 at 1:39 am
    Permalink

    Am I missing something? Where is #1? 

    Reply
  • August 21, 2015 at 10:30 pm
    Permalink

    Oh, I get it now. The stdClass is for defining objects that don't have a class. You probably mentioned it the last video, but I couldn't get my head around it until I saw the example of the person object being defined from the Person class.

    Reply
  • September 2, 2015 at 6:33 am
    Permalink

    This is too amazing.. thanks alot

    Reply
  • January 28, 2016 at 12:32 am
    Permalink

    how do you make sublime ask you to name a new project when you open it?

    Reply
  • March 16, 2016 at 4:43 am
    Permalink

    is the sign "->" in php same as "." in java?

    Reply
  • March 19, 2016 at 2:41 pm
    Permalink

    Hello,
    i need prof. web developer to work with me online
    i need someone who have advance skills in PHP,Jquery,Javascript,Boostarp,css,Mysql,…etc programming
    any one can work online for some hours please contact me

    Reply
  • May 29, 2016 at 7:49 pm
    Permalink

    Someone pls explain to me what does $this mean?

    Reply
  • January 22, 2017 at 10:19 am
    Permalink

    what is the name of the text editor you are using?

    Reply
  • February 15, 2017 at 3:03 am
    Permalink

    sorry but what an ugly explanation of "this"

    Reply
  • March 2, 2017 at 3:38 pm
    Permalink

    You are amazing man you explained everythings well thx alot…

    Reply
  • June 23, 2017 at 1:11 pm
    Permalink

    I' am stil getting a syntax error, unexpected '$person' (T_VARIABLE)

    Reply
  • June 28, 2017 at 7:25 am
    Permalink

    at last someone made a video for me. After wasting lot of time trying to get what this is all about. Thanks, hopefully I can learn oop now

    Reply
  • September 15, 2017 at 8:08 pm
    Permalink

    Good job! Well done! Like for all the videos.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *