Skip to content

Instantly share code, notes, and snippets.

@dshafik
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dshafik/42e934ead6efca49cc20 to your computer and use it in GitHub Desktop.
Save dshafik/42e934ead6efca49cc20 to your computer and use it in GitHub Desktop.
<?php
class Foo {
const BAR = "bat\n";
}
echo Foo::BAR;
// PHP 5.3+
$object = new Foo();
echo $object::BAR;
$string = 'Foo';
echo $string::BAR;
// PHP 7.0+
echo 'Foo'::BAR;
echo ('Foo')::BAR;
echo (function() { return 'Foo'; })()::BAR;
echo (Foo::CLASS)::BAR;
echo ['Foo'][0]::BAR;
function getFoo() {
return 'Foo';
}
echo getFoo()::BAR;
class getFoo {
static public function getStringStatic() {
return 'Foo';
}
public function getString() {
return 'Foo';
}
}
echo getFoo::getStringStatic()::BAR;
$foo = new getFoo();
$foo->getString()::BAR;
$obj = new class() {
public function getString() {
return 'Foo';
}
};
$obj->getString()::BAR;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment