#24499 [Opn]: Notice: Undefined property: stdClass::

From: Date: Sat, 05 Jul 2003 11:26:08 +0000
Subject: #24499 [Opn]: Notice: Undefined property: stdClass::
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969355049@lists.php.net to get a copy of this message
ID: 24499 Updated by: helly@php.net Reported By: wks at wks dot ch Status: Open -Bug Type: PostgreSQL related +Bug Type: Documentation problem Operating System: FreeBSD 4.5 PHP Version: 5.0.0b1 (beta1) New Comment: Make it a doc problem since you obviously didn't read the docs. And close it since it's all your fault :-) What you're missing.... class { private $id; function getId() { $this->id = 1; return $this->id; } } Previous Comments: ------------------------------------------------------------------------ [2003-07-04 11:35:57] wks at wks dot ch Description: ------------ In a class, if 'private' is used instead of 'var' for a variable declaration then it fails with the Notice: Undefined property: stdClassr'. This still occurs if you make '$record = pg_fetch_object($q); return $record->id;' Reproduce code: --------------- <?php class Id { private $id; // var $id; public function getId() { $conn = pg_connect("dbname=db user=user password=pwd"); $q = pg_query($conn, "SELECT id FROM id"); $id = pg_fetch_object($q); return $id->id; } } $id = new Id(); echo $id->getId(); ?> Expected result: ---------------- 1 Actual result: -------------- Notice: Undefined property: stdClass::$id in /path/id_test.php on line 11 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24499&edit=1

« previous php.doc (#969355049) next »