Home > Backend Development > PHP Tutorial > thinkphp这么做是为了啥

thinkphp这么做是为了啥

WBOY
Release: 2016-06-23 13:33:52
Original
1069 people have browsed it

thinkphp中的切面编程里必须用run()方法,但是这个方法怪怪的,因为其中函数定义 的参数在函数中根本没有用到
见下面代码,我查了很多行为类中的run()方法,几乎这个参数都没有用上,如下面代码中的&$params参数,在函数代码就没有出现,即然你不用你thinkphp废这个劲做啥?那么问题来了,thinkphp这种多此一举的行为是不是还隐藏着啥深义!?

public function run(&$params) {        if (C('UPGRADE_NOTICE_ON') && (!S('think_upgrade_interval') || C('UPGRADE_NOTICE_DEBUG'))) {            if(IS_SAE && C('UPGRADE_NOTICE_QUEUE') && !isset($_POST['think_upgrade_queque'])){                $queue=new SaeTaskQueue(C('UPGRADE_NOTICE_QUEUE'));                $queue->addTask('http://'.$_SERVER['HTTP_HOST'].__APP__,'think_upgrade_queque=1');                if(!$queue->push()){                    trace('升级提醒队列执行失败,错误原因:'.$queue->errmsg(), '升级通知出错', 'NOTIC', true);                }                return ;            }            $akey = C('UPGRADE_NOTICE_AKEY');            $skey = C('UPGRADE_NOTICE_SKEY');            $this->accesskey_ = $akey ? $akey : (defined('SAE_ACCESSKEY') ? SAE_ACCESSKEY : '');            $this->secretkey_ = $skey ? $skey : (defined('SAE_SECRETKEY') ? SAE_SECRETKEY : '');            $current_version = C('UPGRADE_CURRENT_VERSION');            //读取接口            $info = $this->send('http://sinaclouds.sinaapp.com/thinkapi/upgrade.php?v=' . $current_version);             if ($info['version'] != $current_version) {                    if($this->send_sms($info['msg']))  trace($info['msg'], '升级通知成功', 'NOTIC', true); //发送升级短信            }            S('think_upgrade_interval', true, C('UPGRADE_NOTICE_CHECK_INTERVAL'));        }    }
Copy after login


回复讨论(解决方案)

你怎么知道不用呢?

目测你是在说 tp的行为驱动

为什么向run提供一个参数。那是有的地方必须向行为提供一个参数,才能正常运行。

还是用的少,才觉得没用

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template