[nycphp-talk] PHP 5 Objects and fsockopen
Joseph Crawford
codebowl at gmail.com
Thu Sep 2 10:13:40 EDT 2004
guys i have a class that is used to open a socket connection, however
i am getting this error
Fatal error: Cannot access undefined property for object with
overloaded property access in D:\htdocs\Nforum\System\Nntp\Nntp.php on
line 40
i am not sure if that is a normal php error or a php 5 error, i am
using the __set and __get methods for part of this object such as the
$errno and $errstr i changed to $this->errno and $this->errstr.
i have posted the code along with this message, if there are any
guru's here that can shed some light on this error i would be much
appreciated.
<?
class Nntp {
static private $instance;
private $host;
private $port;
private $username;
private $password;
private $connection;
private $props;
private function __construct($host, $port, $username, $password) {
$this->host = $host;
$this->port = $port;
$this->username = $username;
$this->password = $password;
$this->timeout = 30;
$this->errno = 0;
$this->errstr = '';
}
static function getInstance($host=null, $port=119, $username=null,
$password=null) {
if(!Nntp::$instance) {
Nntp::$instance = new Nntp($host, $port, $username, $password);
}
return Nntp::$instance;
}
public function __set($name, $value) {
$this->props[$name] = $value;
}
public function __get($name) {
if(isset($this->props[$name])) return $this->props[$name];
else return null;
}
public function Open() {
// THIS IS THE LINE THAT IS KICKING OUT THAT ERROR
$this->connection = fsockopen($this->host, $this->port,
$this->errno, $this->errstr, $this->timeout);
if(!$this->connection) {
echo $this->errstr."(".$this->errno.")<br />\n";
}
}
function isConnected() {
if(is_null($this->connection)) return false;
else return true;
}
}
?>
--
Joseph Crawford Jr.
Codebowl Solutions
codebowl at gmail.com
802-558-5247
More information about the talk
mailing list