【问题标题】:Yii assigns return of require? Help to understandYii 分配 require 的返回?帮助理解
【发布时间】:2016-02-02 12:03:00
【问题描述】:

我刚刚在 Yii MessageCommand.php 中找到了下面这段代码

    $config=require($args[0]);
    $translator='Yii::t';
    extract($config);

https://github.com/yiisoft/yii/blob/master/framework/cli/commands/MessageCommand.php82号线

我认为 require 只能返回 true 或 false。

谁能告诉我这个sn-p。

【问题讨论】:

    标签: php yii return return-value require


    【解决方案1】:

    它是包含范围内的返回变量(如果有'return'语句):

    //index.php
    $a = include('a.php');
    echo $a;//12
    
    ///file a.php
    <?php
    return 12;
    

    【讨论】:

    • 好的,不知道退货。谢谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 2018-12-21
    相关资源
    最近更新 更多