thinkphp项目部署到Linux服务器上报错“模板不存在”如何解决,thinkphplinux
thinkphp项目部署到Linux服务器上报错“模板不存在”如何解决,thinkphplinux
最近一个项目部署到Linux服务器上去的时候,发现某些模板竟然会报错说“模板不存在:/Application/Admin/....”
检查了服务器上的文件,并没有缺少文件,再次上传文件到服务器,还是报错。莫名其妙,怀疑是代码问题。
仔细检查后,发现是模板的文件名问题:
用过TP的都知道:thinkphp会在$this->display()的时候,会自动获取方法名作为模板的文件名,比如一个getUserInfo方法对用着getuserinfo.html的模板文件。
对控制器里的方法,我用驼峰命名法,而view层里的模板名,也是用了驼峰命名法。比如getUserInfo方法对应了getUserInfo.html的模板文件,但是!thinkphp在$this->display()的时候,读取方法名作为模板名,读出来的方法名是小写的,也就是要求模板名为getuserinfo.html。
在Windows下不区分文件名大小写,Linux会区分,所以报错了。
解决办法:要么改模板文件名为小写,要么$this->display('模板文件名')(不带.html)。
细节决定成败,希望这篇文章可以真正的帮助大家,谢谢大家的阅读。

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),