Created
August 13, 2013 17:55
-
-
Save magickatt/6223818 to your computer and use it in GitHub Desktop.
Late Static Binding namespace resolution in PHP
This file contains 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 | |
/* | |
* "Late Static Binding" namespace | |
*/ | |
$class = get_called_class(); | |
$lastSlashPosition = strrpos($class, '\\'); | |
$namespace = substr($class, 0, $lastSlashPosition); | |
// ... or the shorter version | |
$namespace = substr(get_called_class(), 0, strrpos(get_called_class(), '\\')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment