Home>Article>PHP Framework> How to use templates in thinkphp
First of all, you must go to the official website to download the thinkphp framework. Remember to select the thinkphp3.2.2 version, and then unzip it to the desktop or other disks. This is to make it easier for us to find it when using it.
Then open wampserver or other PHP service software, and then open zendstudio (other editors are also acceptable).
Related recommendations: "ThinkPHP Tutorial"
Create a php project, and then Find the folder where you created the project in the www directory, copy and paste the thinkphp file into it, and open the webpage to see if "Welcome to Thinkphp" appears, which means thinkphp is imported successfully.
Then go back to the editor and refresh the project folder. Thinkphp related folders will appear. Find the Application folder and open it. home file, this folder is mainly used to operate the front-end module.
When we open the web page and see the "Welcome to Thinkphp" content, it is controlled and displayed in the Controller class in the home folder. . So to make the template display, we need to change $this->show("..."); to $this->display(); . This is because when we refresh the web page, we will see that the template does not exist. This is because we have not imported the template yet.
At this time we can prompt to create an Index folder under the view folder, and then import the template we want to import, this When we refresh the page, we can see the template page we imported, but there is no style at this time.
Next we need to import the styles to make the page look better. Generally, we put the front-end template styles in the Public folder. , here we copy and paste the relevant styles of the previously imported template into the Public folder.
Simply putting these style files into the Public folder is not enough. We also need to add __PUBLIC__/ in front of the paths where js, cs, image, and these styles are imported. , so that the style can be imported correctly.
Finally refresh the page and we can see the web page template we want. Of course, sometimes the js, css, and style paths are not written properly. This will lead to some effects being impossible to achieve, and then everyone has to rely on themselves.
The above is the detailed content of How to use templates in thinkphp. For more information, please follow other related articles on the PHP Chinese website!