public function canGetProperty($name, $checkVars = true){//property_exists — 检查对象或类是否具有该属性return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);}/*** Returns a value indicating whether a property can be set.* 返回一个值指示是否可以设置一个属性。* A property is writable if:** - the class has a setter method associated with the specified name*   (in this case, property name is case-insensitive);* - the class has a member variable with the specified name (when `$checkVars` is true);** 检查对象或类是否能够设置 $name 属性,如果 $checkVars 为 true,则不局限于是否有 setter** @param string $name the property name* @param boolean $checkVars whether to treat member variables as properties* @return boolean whether the property can be written* @see canGetProperty()*/public function canSetProperty($name, $checkVars = true){return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);//检查对象或类是否能够设置 $name 属性,返回Boolean值。
}/*** Returns a value indicating whether a method is defined.* 返回一个值指示是否定义了一个方法。* The default implementation is a call to php function `method_exists()`.* You may override this method when you implemented the php magic method `__call()`.** 检查对象或类是否具有 $name 方法** @param string $name the method name* @return boolean whether the method is defined*/publicfunction hasMethod($name){return method_exists($this, $name);//返回Boolean值。
}}

下面来介绍console/Controller.php

<?php/*** @linkhttp://www.yiiframework.com/* @copyright Copyright (c) 2008 Yii Software LLC* @licensehttp://www.yiiframework.com/license/*/
namespaceyii\console;
use Yii;
use yii\base\Action;
use yii\base\InlineAction;
use yii\base\InvalidRouteException;
use yii\helpers\Console;/*** Controller is the base class of console command classes.* 控制器是控制台命令类的基类.** A console controller consists of one or several actions known as sub-commands.* 一个控制台控制器由一个或几个动作称为sub-commands。* Users call a console command by specifying the corresponding route which identifies a controller action.* 用户调用一个控制台命令通过指定相应的路线确定控制器动作* The `yii` program is used when calling a console command, like the following:* yii的程序调用时使用控制台命令,如下:** ~~~* yii <route> [--param1=value1 --param2 ...]* ~~~*** @property string $help This property is read-only.* @property string $helpSummary This property is read-only.** @author Qiang Xue <qiang.xue@gmail.com>* @since 2.0*/
class Controller extends \yii\base\Controller
{const EXIT_CODE_NORMAL = 0;const EXIT_CODE_ERROR = 1;/*** @var boolean whether to run the command interactively.* 是否运行该命令交互*/public $interactive = true;/*** @var boolean whether to enable ANSI color in the output.* 是否支持ANSI颜色在输出* If not set, ANSI color will only be enabled for terminals that support it.* 如果没有设置,ANSI颜色只会支持终端支持它。*/public$color;

转载于:https://www.cnblogs.com/taokai/p/5451188.html

yii2框架随笔19相关推荐

  1. yii2框架随笔29

    今天我们来看UrlRule.php <?php/*** @linkhttp://www.yiiframework.com/* @copyright Copyright (c) 2008 Yii ...

  2. yii2框架-yii2的组件和服务定位器(四)

    上一节主要是分析了yii2的自动加载函数,下面在分析一下yii2的核心组件与服务定位器. 其实yii2的核心组件主要有以下: //日志组件 'log' => ['class' => 'yi ...

  3. php的yii2框架下开发环境xampp,vim,xdebug,DBGp的搭建

    2019独角兽企业重金招聘Python工程师标准>>> 引言 Yii1.1的搭建过程见这里.下面做少许改动,加入composer部分,使之用于Yii2. 选择Linux桌面环境Dee ...

  4. Yii2框架源码分析之如何实现注册和登录

    注册 在advanced模板中,进入frontend/index.php?r=site%2Fsignup页面,可以看到框架的注册页面 填写完Username.Email和Password后点击Sign ...

  5. 在YII2框架中使用UEditor编辑器发布文章

    在YII2框架中使用UEditor编辑器发布文章 创建文章数据表 文章数据表主要有4个字段 id  主键(int) title 标题(varchar) content 内容(text) created ...

  6. yii引入php文件,Yii2框架中CSS、JS文件引入要领_PHP开发框架教程

    在yii2中,因为yii2版本升级致使了,许多yii2的用法跟yii1有着很大的区分,这几天一直在view层的视图界面徜徉着,碰到什么问题呢? (引荐进修:yii框架) 问题就是搞不清我该怎样去引入C ...

  7. YII2框架的excel表格导出

    2019独角兽企业重金招聘Python工程师标准>>> 最近的项目做到关于表格输出的功能,之前用TP的时候也做过,趁着这次功能比较多样的机会整理一下 本文是基于YII2框架进行开发的 ...

  8. php 接收curl json数据格式,curl发送 JSON格式POST数据的接收,以及在yii2框架中的实现原理【精细剖析】...

    1.通过curl发送json格式的数据,譬如代码: function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ ...

  9. yii 加载php文件,Yii2框架加载css和js文件的方法分析

    本文实例讲述了Yii2框架加载css和js文件的方法.分享给大家供大家参考,具体如下: 1.第一步是要把我们的css.js文件放到web目录下 2.第二步修改assets/AppAsset.php文件 ...

最新文章

  1. Ubuntu 安装 IPython、jupyter notebook
  2. android如何看百分比版本,【JAVA】Android百分比布局
  3. Blender与UE5完美结合全流程创作游戏资产视频教程
  4. 学习在 ArcEngine 中使用 Geoprocessing
  5. 华为诺亚开源贝叶斯优化库:超参数调优河伯、组合优化器CompBO
  6. 数据结构与算法之递归题目
  7. mysql数据库命令_新手入门MYSQL数据库命令大全
  8. android ems的作用,对话框主题活动中忽略android:minEms
  9. linux脚本彩色提示,在shell脚本里显示带颜色的字(linux)
  10. 汉诺塔游戏(Python)
  11. 由浅入深 学习 Android Binder(十一) binder线程池
  12. 加密与解密 入侵检测 扫描与抓包
  13. 基于Unity尝试唇同步/LipSync/OVRLipSync(附Demo及源码)
  14. OLAP、OLTP的介绍和比较
  15. ASEMI整流桥GBU808参数,GBU808介绍,GBU808详解
  16. 期货分仓系统搭建子账户功能
  17. 设置dvorak键盘
  18. internal 和 external
  19. there is no getter for property named 错误
  20. 限流断路器与普通断路器的区别与联系

热门文章

  1. Apollo 对表名区分大小写 如何配置MYSQL不区分大小写呢
  2. Java经纬度坐标与高斯坐标的转换
  3. Mybatis 查询返回List<String>集合
  4. java查看当前活动的线程数量
  5. java用循环做猜拳_java用循环方式实现和计算机玩猜拳的程序
  6. 蠕虫mysql_mysql蠕虫复制基础知识点
  7. Javascript中数组的sort方法的分析
  8. 2017-2018-1 20155301 《信息安全系统设计基础》第十三周学习总结
  9. PIX防火墙security context配置手册(虚拟防火墙技术)
  10. (记录合并)union和union all的区别