zoukankan      html  css  js  c++  java
  • yaf配置通用函数

    yaf配置通用函数
    在Bootstrap.php中加载

    /**
     * 通用函数配置
     */
    public function _initCommonFunctions(){
    //        Yaf_Loader::import(Yaf_Application::app()->getConfig()->app->root_path . '/library/common/functions.php');
        Yaf_Loader::import(App::getConfig('app.root_path') . '/library/common/functions.php');
    }
    

    然后,在里面写通用的函数,就可以了!

    <?php
    /**
     * 通用函数库
     */
    function test() {
        echo "test";
    }
    
    

    也可以引入类

    /**
     * 通用函数配置
     */
    public function _initCommonFunctions(){
        Yaf_Loader::import(App::getConfig('app.root_path') . '/library/common/Func/Func.php');
    }
    
    <?php
    namespace commonFunc;
    
    /**
     * 通用函数库
     */
    class Func {
        /**
         * 上午下午
         */
        public static function test()
        {
            $no = date('H');
            $return = '您好';
            if ($no > 0 && $no <= 6) {
                $return = '凌晨好';
            }
            if ($no > 6 && $no < 12) {
                $return = '上午好';
            }
            if ($no >= 12 && $no <= 18) {
                $return = '下午好';
            }
            if ($no > 18 && $no <= 24) {
                $return = '晚上好';
            }
            return $return;
        }
    }
    

    使用

    echo Func::test();
    
  • 相关阅读:
    哈希表--扩展数组
    哈希表效率
    P=(1+1/(1-L))/2
    函数推进
    简单函数2
    简单函数
    getting data from the keybroad
    nutch-2.2.1 hadoop-1.2.1 hbase-0.92.1 集群部署(实用)
    hbase zookeeper独立搭建
    Orchard 介绍
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/12110912.html
Copyright © 2011-2022 走看看