刚升级的ThinkPHP 3.2.2中突然发现,在3.1版本好用的getActionName方法,在ThinkPHP 3.2.2中居然没有
刚升级的ThinkPHP 3.2.2中突然发现,在3.1版本好用的getActionName方法,在ThinkPHP 3.2.2中居然没有,出现了令人胆寒的哭相:
纠结呀,没得办法自己动手丰衣足食,添加进去,按图索骥,根据提示找到Controller.class.php,手动添加如下代码:/**<br>
* 获取当前Action名称<br>
* @access protected<br>
*/<br>
protected function getActionName() {<br>
if(empty($this->name)) {<br>
// 获取Action名称<br>
$offset=strrpos(get_class($this), '\\', -10); // 从尾部第 10 个位置开始查找<br>
$this->name = substr(get_class($this),$offset+1,-10);<br>
}<br>
return $this->name;<br>
}
然后在可以在控制器中正常是用getActionName()方法获取控制器名称了:$name=$this->getActionName();
AD:真正免费,域名+虚机+企业邮箱=0元

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

Dreamweaver CS6
Visual web development tools

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),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
