thinkphp中配置信息的二维数组设置与使用

简介:

有时候配置信息是二维数组

1.配置

<?php
return array (
  // 阿里大鱼短信配置
  'dayu_appkey'=>'xxx',
  'dayu_secretKey'=>'xxxxxx',
  'dayu_template_register' => array('signname'=>'注册验证','templatecode'=>'SMS_4910100'),
  'dayu_template_alteration' => array('signname'=>'变更验证','templatecode'=>'SMS_4910097'),
  'dayu_template_identity' => array('signname'=>'身份验证','templatecode'=>'SMS_4910103'),
  
);

2.使用,通过点的方式调用

// template_type 1 注册验证 2 变更验证 3 身份验证
protected function sendDayuSms($tel,$code,$template_type,$product = "【多多助店宝】") {
    if ($template_type == 1) {
        $signname = C('dayu_template_register.signname');
        $templatecode = C('dayu_template_register.templatecode');
    }

    if ($template_type == 2) {
        $signname = C('dayu_template_alteration.signname');
        $templatecode = C('dayu_template_alteration.templatecode');
    }

    if ($template_type == 3) {
        $signname = C('dayu_template_identity.signname');
        $templatecode = C('dayu_template_identity.templatecode');
    }
    
    require LIB_PATH . 'ORG/Taobao-sdk-php/TopSdk.php';
    $c = new TopClient;
    $c->appkey = C('dayu_appkey');
    $c->secretKey = C('dayu_secretKey');
    $req = new AlibabaAliqinFcSmsNumSendRequest;
    $req->setSmsType("normal");
    $req->setSmsFreeSignName("{$signname}");
    $req->setSmsParam('{"code":"'. $code .'","product":"'. $product .'"}');
    $req->setRecNum("{$tel}");
    $req->setSmsTemplateCode("{$templatecode}");
    $resp = $c->execute($req);
    return $resp;
}

输出其中一个值

array(2) {
["signname"] => string(12) "身份验证"
["templatecode"] => string(11) "SMS_4910103"
}



本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/5347752.html,如需转载请自行联系原作者


相关文章
|
11月前
|
Java Maven Spring
maven项目,动态读取外部配置文件
maven项目,动态读取外部配置文件
235 0
|
2月前
|
PHP
thinkphp修改分页配置文件
thinkphp修改分页配置文件
19 0
|
4月前
|
前端开发 JavaScript Java
springboot 出现 Cannot resolve MVC View ‘index‘ 问题解决办法,前后端不分离项目前端文件存放位置,已经如何访问
springboot 出现 Cannot resolve MVC View ‘index‘ 问题解决办法,前后端不分离项目前端文件存放位置,已经如何访问
147 0
|
7月前
|
Java Spring
08 SpringBoot配置文件加载位置
08 SpringBoot配置文件加载位置
22 0
|
10月前
Web 项目如何读取外部配置文件
Web 项目如何读取外部配置文件
|
11月前
|
SQL 缓存 开发框架
THINKPHP5中的config设置实例
THINKPHP5中的config设置实例
121 0
|
关系型数据库 MySQL 数据库
idea里面mysql数据库统一配置文件和存放到集合中读取出来详细步骤
统一配置可以方便后期代码的维护,比如更改mysql的密码或者什么就可以直接在资源配置文件里面更改就好,不用到代码里面去更改了。
134 0
idea里面mysql数据库统一配置文件和存放到集合中读取出来详细步骤
|
运维 Java 开发者
配置文件的加载位置|学习笔记
快速学习配置文件的加载位置
113 0
配置文件的加载位置|学习笔记
|
PHP
laravel创建admin文件夹,里边的indexController怎么写
laravel创建admin文件夹,里边的indexController怎么写
184 0