zoukankan      html  css  js  c++  java
  • php-构造函数-返回值

    class NewClass {
    
        public function __construct () {
            return 'Hello World!!';
        }
         
    }
     
    $info = new NewClass;
    echo $info -> __construct();
        function __construct($conf=array())
        {
            if($conf){
                return $this->connect($conf['host'], $conf['username'], $conf['secret']);
            }else{
                $config = @parse_ini_file('/etc/asterisk/manager.conf', true);
                $telnat = array();
                foreach ($config as $key => $value){
                    if($key !=="general"){
                        $telnat['user'] = $key;
                        $telnat['secret'] = $value['secret'];
                    }else{
                        $telnat['port'] = $value['port'];
                    }
                }
    //            return $this->connect('localhost:' . $config['general']['port'], 'admin', $config['admin']['secret']);
                $info  =  $this->connect('localhost:' . $telnat['port'], $telnat['user'], $telnat['secret']);
                if($info !== false){
                     return    $this->connect('localhost:' . $telnat['port'], $telnat['user'], $telnat['secret']);
                }
                if($info === false){
                  return 'false';
                }
            }
        }
    
    
        if ($this->socket == false) {
    //            $this->log("Unable to connect to manager {$this->server}:{$this->port} ($errno): $errstr");
    //            socket 连接失败,程序自动终止
    //            exit("Unable to connect to manager {$this->server}:{$this->port} ($errno): " . iconv("gb2312", "UTF-8", $errstr));
    //            die(false);
                return false;
            }
  • 相关阅读:
    PHP preg_replace_callback_array() 函数
    PHP preg_quote() 函数
    PHP preg_match() 函数
    SqlHelper工具类
    ArrayListd的长度问题
    事务
    Socket通信
    时间戳,产生随机数
    背景大小 | background-size (Backgrounds & Borders)
    背景图片位置 | background-position (Backgrounds & Borders)
  • 原文地址:https://www.cnblogs.com/CWQPHP/p/10690476.html
Copyright © 2011-2022 走看看