It’s in the index.php entry file in the root directory public. This file is introduced in the register function in the boot file, as explained in the second section of the source code. Here is a detailed look at the source of this file.
if(! function_exists('class_basename')) {
/** * gets the class name (excluding the namespace) **@param string|object $class
* @return string
*/
function class_basename($class) {
// If the argument passed is of type object, get the class name, otherwise equal to itself.
$class = is_object($class) ? get_class($class) : $class;
// Get the class name if \Think\Loader becomes /Think/Loader and returns Loader
return basename(str_replace('\ \'), '/', $class); }}if(! function_exists('class_uses_recursive')) {
/** * Gets all the traits used in a class, including the parent class's **@param $class
* @return array
*/
function class_uses_recursive($class) {
// If it is an object, get the class name directly
if (is_object($class)) {
$class = get_class($class);
}
$result = [];
// Loop through the array, calling trait_uses_recursive. Here are...
foreach(array_merge([$class => $class], class_parents($class)) as$class) { $result += trait_uses_recursive($class); }}}if(! function_exists('trait_uses_recursive')) {
/** * Retrieve all references to traits ** in a trait@param string $trait
* @return array
*/
function trait_uses_recursive($trait)
{
// Return the array of traits used in class.
$traits = class_uses($trait);
// Loop over all traits
foreach($traits as $trait) {
$traits += trait_uses_recursive($trait);
}
return$traits; }}if(! function_exists(classnames)) {/** * CSS style name generator * classnames("foo", "bar"); // => "foo bar" * classnames("foo", [ "bar"=> true ]); // => "foo bar" * classnames([ "foo-bar"=> true ]); // => "foo-bar" * classnames([ "foo-bar"=> false ]); // => " * classnames([ "foo" => true ], [ "bar"=> true ]); // => "foo bar" * classnames([ "foo" => true, "bar"=> true ]); // => "foo bar" * classnames("foo", [ "bar"=> true, "duck"=> false ], "baz", [ "quux"=> true ]); // => "foo bar baz quux" * classnames(null, false, "bar", 0, 1, [ "baz"=> null ]); // => "bar 1" */
function classnames(a)
{
// Get the parameters returned as an array
$args = func_get_args();
// Use array_map to traverse the array
$classes = array_map(function ($arg) {
// If there are arguments in the array format
if (is_array($arg)) {
// Return whitespace separated strings and display false values with array_map and sort false values with array_filter
return implode("", array_filter(array_map(function ($expression, $class) {
return $expression ? $class : false;
}, $arg, array_keys($arg))));
}
// Finally, ensure that each element in the array is a space-separated string
return $arg;
}, $args);
// Returns a space-separated string
return implode("", array_filter($classes)); }}Copy the code