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; }