Posted in PHP onSeptember 11, 2019
本文实例讲述了Yii参数配置文件params用法。分享给大家供大家参考,具体如下:
1.标题的调用
1.1设置
<?php return [ 'title' => '图书商城', "domain" => [ 'www' => 'http://super.nat300.top/', 'm' => 'http://super.nat300.top/m', 'web' => 'http://super.nat300.top/web', 'weixin' => 'http://super.nat300.top/weixin', ], "upload" => [ 'avatar' => "/uploads/avatar", 'brand' => "/uploads/brand", 'book' => "/uploads/book", ], "weixin" => [ "appid" => 'wxc01ba9b834be5023', "sk" => 'da1e24dd41859f769b23c089f827268c', "token" => 'tomalang689', "aeskey" => 'P6PaB6bPrRzKkva5lq6kHWtYkOOlVhYq4fh1iR7LMKB', 'pay' => [ 'key' => '', 'mch_id' => '', 'notify_url' => [ 'm' => '/pay/callback' ] ] ] ];
1.2调用
这个只是简单的调用参数的方法
<title><?=Yii::$app->params['title'];?></title>
2.URL的拼凑
2.1设置
<?php return [ 'title' => '编程商城', 'domain' => [ 'www' => 'http://book_my.aa.test', 'm' => 'http://book_my.aa.test/m', 'web' => 'http://book_my.aa.test/web' ],
2.2 调用
public static function buildMUrl( $path,$params = [] ){ $domain_config = \Yii::$app->params['domain']; $path = Url::toRoute(array_merge([ $path ],$params)); return $domain_config['m'] .$path; }
3.加载顺序
后面的会覆盖前面的
1、common/config/params.php
2、common/config/params-local.php
3、frontend/config/params.php
4、frontend/config/params-local.php
The controller ID is:
<?= $this->context->id ?>
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
Yii框架参数配置文件params用法实例分析
- Author -
阿朗999声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@