Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End What do you call php variables like this: $this->hello

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26045
    mattvot
    Member

    They must have a name but I can’t find it.

    What’s the arrow called?

    #63673
    mattvot
    Member

    hmm, That sort of makes sense. Sometimes I see them with a function like:

    Code:
    $this->function();
    #64289

    Well, pHp is quite similar to c / c++ and in c++, the term obj->item is used to access the item of the class of which obj is an object.
    Don’t know if it means the same here in pHP or not.Anyway, I have to brush up my C++ a bit.. been ages since I last used it. Am more of a C guy hehe. Will study a bit and get back to you :)

    #64313
    Argeaux
    Participant

    You use this when you access a variable which is set in a class. These variables are called properties of a class.

    $this-> stands for a property in the current class you are working in. and hello for the name.

    Code:

    So in the example above $this->hello stands for ‘hello doug’.

    Its used in objective oriented programming in php (or short: OOP).
    So maybe you can find more info with those words.

    #64324
    Rob MacKay
    Participant

    yup the guys above are right – you could set up a new object by assigning for example a class you made to connect to a database…

    $this = new connection();

    connection is the class you are accessing – inside the class are the functions – (well methods if they are inside a class – but hey…)

    you can then access the functions/methods via the "->"

    $this->addNew();

    if you see "=>" that is what defines a key within an array – it can be a little double take-ish when you first see it though…

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.