-
-
Save dshafik/42e934ead6efca49cc20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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