Sunday 12 October 2014

[dcphp-dev] PHP self:: vs static::

In this code snippet, I get output that says "keykey"

What is the difference between the meanings of static:: and self:: in
this or any other context. Any man page reference would be gratefully
received!

<?php
error_reporting(E_ALL);

Class Thing
{
const PRIMARY_KEY = 'key';

public function keys()
{
$x = self::PRIMARY_KEY;
$y = static::PRIMARY_KEY;
return $x . $y;
}
}

$thing = new Thing;
var_dump($thing->keys());

Thanks and regards, Ray

--
You received this message because you are subscribed to the Google
Group: "Washington, DC PHP Developers Group" - http://www.dcphp.net
To post, send email to washington-dcphp-group@googlegroups.com
To unsubscribe, send email to washington-dcphp-group+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/washington-dcphp-group?hl=en
---
You received this message because you are subscribed to the Google Groups "Washington, DC PHP Developers Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to washington-dcphp-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 comments:

Post a Comment