Regarding the issue of the import path of thinkphp5.1 files
This article mainly introduces the issue of the thinkphp5.1 file introduction path. This article introduces it to you in very detail and has certain reference value. Friends in need can refer to
Thinkphp5.1 file introduction
1. Introduce other view files into the view file
The file directory is as shown below:
It is necessary to introduce the four html template files under the public folder into index.html. The index.html introduction code is as follows:
{include file="/public/_meta"} {include file="/public/_header"} {include file="/public/_menu"} <p>中间部分填写页面特有的内容</p> {include file="/public/_footer"}
Through this This method can extract common and infrequently changed content and avoid code redundancy.
2. Introduce the static files under the public file into the view file
The file directory is as shown below:
We need to introduce some static css and js files into the view template of index.html. These files are generally stored in the public directory. We now use relative paths to introduce these files, and the index.html file is introduced. The code is as follows:
<link rel="stylesheet" type="text/css" href="/../static/Hadmin/static/h-ui/css/H-ui.min.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="/../static/Hadmin/static/h-ui.admin/css/H-ui.admin.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="/../static/Hadmin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="/../static/Hadmin/static/h-ui.admin/skin/default/skin.css" rel="external nofollow" id="skin" /> <link rel="stylesheet" type="text/css" href="/../static/Hadmin/static/h-ui.admin/css/style.css" rel="external nofollow" />
In my test project, the above code was introduced successfully. If the introduction fails during actual practice, don't worry, here is a method to facilitate debugging: first, refresh your web page; second step, right-click to view the source code of the web page; third step, copy the corresponding file introduction link and add it to the new page Open in; The fourth step is to check the file path actually recognized by the browser, and adjust the URL to the correct file path until the file content can be correctly accessed; the fifth step is to refer to the file path that can be used Existing paths can be improved.
3. Define global variables yourself and use them in the template file.
It needs to be explained that tp5.1 changed the configuration variable name. As follows:
'tpl_replace_string' => [ '__STATIC__' => '/static', ],
Specific implementation steps:
1. Add the constants you need to define in Config/template.php.
2. You can use it directly in the template, as follows:
<link rel="stylesheet" type="text/css" href="__STATIC__/Hadmin/static/h-ui/css/H-ui.min.css" rel="external nofollow" />
The specific setting of this path depends on your actual project directory. , you can change it yourself.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
How to use ThinkPHP to integrate datatables to implement server-side paging
Parsing of variable output of ThinkPHP template engine
The above is the detailed content of Regarding the issue of the import path of thinkphp5.1 files. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

The methods to obtain the file path in C++ are: 1. Use the std::filesystem library. 2. Use Boost library. These methods can be used to get the absolute path, root directory, parent directory, and extension of a file. In practice, these techniques can be used to display file lists in user interfaces.

Solution to the problem that the path cannot be found for Python file download: Make sure the download path exists and has write permission. Checks whether the user has write permission to the file in the specified path. If using relative paths, make sure they are relative to the current working directory. Use the os.path.abspath() function to convert a relative path to an absolute path.

How to display the file path in Linux In the Linux operating system, you can use some simple commands to view the path of a file. These commands can help users quickly locate the location of files and facilitate file management and operation. The following will introduce several methods of displaying file paths, with specific code examples. 1. Use the pwd command. The pwd command can display the absolute path of the current working directory. Just enter the pwd command in the terminal to display the full path of the current working directory. Here is an example: $pw

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

"Development Suggestions: How to Use the ThinkPHP Framework to Implement Asynchronous Tasks" With the rapid development of Internet technology, Web applications have increasingly higher requirements for handling a large number of concurrent requests and complex business logic. In order to improve system performance and user experience, developers often consider using asynchronous tasks to perform some time-consuming operations, such as sending emails, processing file uploads, generating reports, etc. In the field of PHP, the ThinkPHP framework, as a popular development framework, provides some convenient ways to implement asynchronous tasks.
