self:: refers to the class context inside of the class. parent refers to the class which the current class extends. $this refers to the object context of a class. Self is a PHP5 only keyword (I think).
class a
{
private $a;
function __construct()
{
$this->a = 1;
}
}
$a = new a; // Makes an instance of class a and sets member var $a to 1;
class b extends a
{
function __construct()
{
parent::__construct();
}
}
$b = new b; // Calls constructor of parent object
class c
{
const MYCONST = "A value";
function c()
{
echo self::MYCONST;
self::d();
}
function d()
{
echo "Objects in PHP5 are happy objects!";
}
}
c::c(); // Calls class c statically, and displays the constant MYCONST
Note that self is only used in class context and not in object context, so it can't be used on member variables (which only exist in object context).
Hope this helps 🙂