PHP Difference between __FUNCTION__ and __METHOD__


Example

__FUNCTION__ returns only the name of the function whereas __METHOD__ returns the name of the class along with the name of the function:

<?php

class trick
{
    public function doit()
    {
        echo __FUNCTION__;
    }

    public function doitagain()
    {
        echo __METHOD__;
    }
}

$obj = new trick();
$obj->doit(); // Outputs: doit
$obj->doitagain();  // Outputs: trick::doitagain