English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
1loading static resource path
greater than5.0.4The version can be used directly
__ROOT__ : project directory
__STATIC__ : project directory under static directory
__JS__ : project directory under static/js directory
__CSS__: project directory under static/css directory
We can use the view template to print the specific paths of these constants
!DOCTYPE html> <html> <head> <meta charset="UTF-8> <title>Insert title here</title> </head> <body> __ROOT__<br> __STATIC__<br> __JS__<br> __CSS__<br> </body> </html>
The page output is as follows:
/ /projectname/public/static /projectname/public/static/js /projectname/public/static/css
Open the config file under the application folder, you can customize the resource constants according to your own needs, and after defining them, you can use the constants in template files.
For example:
<? 'view_replace_str' => [ '__PUBLIC__'=>'../public/static/ '__ROOT__' => '',/ '__APP__' => 'app// ]
2predefined constants
Predefined constants refer to the constants predefined by the system, which do not change with the environment, including:
EXT library file suffix (.php)
THINK_VERSION framework version number
3path constants
System and application path constants are used for the system's default directory specifications and can be changed by redefinition. If you do not want to customize the directory, these constants generally do not need to be changed.
DS current system directory separator THINK_PATH framework system directory ROOT_PATH framework application root directory APP_PATH directorio de aplicación (por defecto application) CONF_PATH directorio de configuración (por defecto APP_PATH) LIB_PATH directorio de bibliotecas del sistema (por defecto THINK_PATH.'library/) CORE_PATH directorio de bibliotecas de núcleo del sistema (por defecto LIB_PATH.'think/) TRAIT_PATH directorio de trait del sistema (por defecto LIB_PATH.'traits/) EXTEND_PATH directorio de bibliotecas de extensión (por defecto ROOT_PATH . 'extend/) VENDOR_PATH directorio de bibliotecas de terceros (por defecto ROOT_PATH . 'vendor/) RUNTIME_PATH directorio de ejecución de aplicación (por defecto ROOT_PATH.'runtime/) LOG_PATH directorio de registro de aplicación (por defecto RUNTIME_PATH.'log/) CACHE_PATH directorio de caché de plantillas del proyecto (por defecto RUNTIME_PATH.'cache/) TEMP_PATH directorio de caché de aplicación (por defecto RUNTIME_PATH.'temp/)
4、constantes del sistema
Las constantes del sistema pueden cambiar con el cambio del entorno de desarrollo o la configuración.
IS_WIN si es entorno de Windows IS_CLI si es modo de línea de comandos THINK_START_TIME tiempo de inicio de ejecución (marca de tiempo) THINK_START_MEM uso de memoria al comenzar a ejecutarse ENV_PREFIX prefijo de configuración de variables de entorno
Resumen
Lo que se mencionó anteriormente es lo que el editor les ha presentado a todos sobre thinkphp5 El método de ruta de recursos estáticos y las constantes, espero que les sea útil. Si tienen alguna pregunta, dejen un mensaje y el editor les responderá a tiempo!