Created
March 22, 2012 03:15
-
-
Save codenamegary/2155375 to your computer and use it in GitHub Desktop.
PSR-0 Compatible regex class loader
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 | |
echo "<PRE>"; | |
$regex = "^\\\([a-zA-Z_]+){1}\\\([a-zA-Z_]+){1}\\\?([a-zA-Z]+)?_?([a-zA-Z]+)?_?([a-zA-Z]+)?_?([a-zA-Z]+)?$"; | |
echo "Regex: " . $regex . "\r\n"; | |
// Change Class name to test accordingly for whatever your class name is | |
if (isset($_GET['classname'])) { $className = $_GET['classname']; } else { $className = "\\Vendor\\Namespace\\Class"; } | |
echo "Class Name: " . $className . "\r\n"; | |
preg_match('/'.$regex.'/',$className,$matches) or die('invaid class name'); | |
//print_r($matches); | |
unset($matches[0]); | |
$filename = implode(DIRECTORY_SEPARATOR,$matches) . '.php'; | |
echo "Filename: " . $filename; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment