write a function to manage the acquisition, and call this function when you need to get it.
function getToken()
{
$token = require('tokens.php');
return $token;
}
files introduced according to the current trend will be automatically introduced by psr4.
you can find information about the registry mode.
ps: wants to be able to use variables directly everywhere. No, it can only be obtained through functions. Is it better to use less global variables
items without composer
management? You can use the autoload
mechanism. It must be annoying to have require in every file header.
Import a global configuration file
so the variables in the configuration are in the lifecycle of PHP
define an autoload class by yourself, and then use the _ _ call () method to get it automatically, or you can do it directly with session, which is also possible. If it is native, you have to write the autoload class yourself. If it is a framework, there are many global ones, or you can write it into public methods such as tp5's common.php file
entry file mode. All programs will enter the entry file, so you can define it. This is how frameworks are defined.
exists in session or redis