Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Late Static Binding namespace resolution in PHP
<?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
You can’t perform that action at this time.