刚升级的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,手动添加如下代码:/**<code class="prettyprint linenums lang-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>
}
* 获取当前Action名称$name=$this->getActionName();
* @access protected
*/
protected function getActionName() { if(empty($this->name)) { // 获取Action名称 $offset=strrpos(get_class($this), '\', -10); // 从尾部第 10 个位置开始查找 $this->name = substr(get_class($this),$offset 1,-10); } return $this->name; }然后在可以在控制器中正常是用getActionName()方法获取控制器名称了: AD:真正免费,域名 虚机 企业邮箱=0元
热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

Dreamweaver CS6
视觉化网页开发工具

Dreamweaver Mac版
视觉化网页开发工具

SublimeText3 Linux新版
SublimeText3 Linux最新版