Jump to content

Help with calling a function


yoda699

Recommended Posts

Hey, I'm in the process of teaching myself stuff (Yes, I am a total beginner). And I got a question about a part of a code that I don't understand.

if(isset($_POST['sublogin'])){
         $this->procLogin();
      }
else {
echo "blah blah";
}

 

The first line of the code I understand. I also understand how you call a function. What i don't understand is what does

$this-> stands for?

 

Does it mean that its a call for a function on the same page?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/182779-help-with-calling-a-function/
Share on other sites

That means that the code you have is within a method (function) of a class, and it is calling another method (function) within that same class.  In other words, "call procLogin() of this class"

 

class something {

  function abc () {
    // do something
  }

  function xyz() {
    // call function abc in class something.  Since it is in the same class as this function, 
    // you can say "$this" as a shortcut
    $this->abc();
  }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.