What's $this?

Simple question, what's $this - a or b?

<?php
class a {
    function aa(){
        var_dump($this);
    }

}

class b {
    function bb(){
        a::aa();
    }

}

$b_obj = new b;
$b_obj->bb();
?>

Answer: object(b)#1 (0) { }

Bookmark and Share

Somewhat related posts

2 Responses to “What's $this?”

  1. rajesh Says:

    Althoug code is very small, but thats sufficient to explain the meaning of $this. I loved it.
    Thanks for a brainy posting.

  2. mohammed Alkhateeb Says:

    the answer is a , because $this that mean this is to this class

Leave a Reply