0
我有這樣的:只有變量可以通過引用傳遞 - opensocket問題
final public function __construct()
{
$this->_host = 'ssl://myserver.com';
$this->_porto = 700;
$this->_filePointer = false;
try
{
$this->_filePointer = fsockopen($this->_host, $this->_porto);
if ($this->_filePointer === FALSE)
{
throw new Exception('Cannot place filepointer on socket.');
}
else
{
return $this->_filePointer;
}
}
catch(Exception $e)
{
echo "Connection error: " .$e->getMessage();
}
}
但我想超時選項添加到這一類,所以我說:
final public function __construct()
{
$this->_host = 'ssl://myserver.com';
$this->_porto = 700;
$this->_filePointer = false;
$this->_timeout = 10;
try
{
$this->_filePointer = fsockopen($this->_host, $this->_porto, '', '', $this->_timeout);
if ($this->_filePointer === FALSE)
{
throw new Exception('Cannot place filepointer on socket.');
}
else
{
return $this->_filePointer;
}
}
catch(Exception $e)
{
echo "Connection error: " .$e->getMessage();
}
}
我m得到錯誤說:「只有變量可以通過引用傳遞。」
發生了什麼事?
更新: 錯誤: 「只有變量可以通過引用傳遞」 是關係到這條線:
$this->_filePointer = fsockopen($this->_host, $this->_porto, '', '', $this->_timeout);
非常感謝, MEM
(嘆氣)*你在哪一行*得到錯誤? – 2010-12-17 11:36:15
@皮卡 - 謝謝。我已更新我的問題。 Ps-我需要那些'','',在那裏嗎? – MEM 2010-12-17 11:42:53