PHP中$ this的真正定义是什么?

I currently am using PHP and was reading the PHP manual but still have a problem with $this.

Is $this something global or is it is just another variable name to build objects on?

Here is an example:

public function using_a_function($variable1, $variable2, $variable3)
{
    $params = array(
        'associative1' => $variable1,
        'associative2' => $variable2,
        'associative3' => $variable3
    );
    $params['associative4'] = $this->get_function1($params);
    return $this->get_function2($params);
}

How would $this work for the return function? I guess I am confused on how this function builds. I understand building the associate array part with a name being a valuekey names => value, but $this throws me off on this example.

It is refered to as the Object scope, lets use an example class.

Class Example
{
    private $property;
    public function A($foo)
    {
         $this->property = $foo;
         // we are telling the method to look at the object scope not the method scope
    }
    public function B()
    {
         return self::property; // self:: is the same as $this
    }
}

We can now instance our object and use it in another way also:

$e = new Example;
$e::A('some text');
// would do the same as
$e->A('some other text');

This is just a way of accessing the scope of the Object because methods cannot access other method scopes.

You can also extend a class and use the parent:: to call the class extension scope, for example:

Class Db extends PDO
{
    public function __construct()
    {
        parent::__construct(....

Which would access the PDO construct method rather than its own construct method.

In your case, the method is calling other methods that are in the object. Which can be called using $this-> or self::

$this is only used in object oriented programming (OOP) and refers to the current object.

class SomeObject{
    public function returnThis(){
        return $this;
    }
}

$object = new SomeObject();
var_dump($object === $object->returnThis()); // true

This is used inside the object to reach member variables and methods.

class SomeOtherClass{
    private $variable;
    public function publicMethod(){
        $this->variable;
        $this->privateMethod();
    }
    private function privateMethod(){
        //
    }
}