The code is very simple, just pay attention to the comments.
The code is as follows:
/**
* Import module file
*
* @param string $classString Import file path string, you can use "." instead of "/"
* @param string $fileType The extension of the imported file type (with "." sign), or it can be class/inc (abbreviation)
* @return Exception Returns true if the import is successful, otherwise returns an exception object
*
* @example
* importModule('gapi.Account') => include_once('modules/gapi/Account.class.php');
*/
function importModule($classString, $fileType = 'class')
{
$filename = $module_path.strtr($classString, '.', '/');
switch ($fileType) {
//Import class file
case 'class': $filename .= '.class.php'; break;
//Import included files
case 'inc': $filename .= '.inc.php'; break;
//Customize the extension of the imported file
default: $filename .= $fileType; break;
}
if (is_file($filename))
{
include_once($filename);
}
else
{
exit('class "\' . strtr($classString, '.', '\') . '" is not found.');
}
}
The above is the code shared with you in this article, I hope you like it.
http://www.bkjia.com/PHPjc/969347.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969347.htmlTechArticlephp import module file sharing This article will share with you the php import module file sharing. The main parameters are the import file path characters. String, you can use . instead of /, import the extension of the file type (with...