Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36246 invoked from network); 12 Jul 2003 19:09:39 -0000 Received: from unknown (HELO smtp2.ex.eclipse.net.uk) (212.104.129.133) by pb1.pair.com with SMTP; 12 Jul 2003 19:09:39 -0000 Received: from 10.0.0.1 (unknown [213.152.58.41]) by smtp2.ex.eclipse.net.uk (Postfix) with ESMTP id B4A749F21A for ; Sat, 12 Jul 2003 20:04:05 +0100 (BST) Reply-To: hudzilla@php.net To: internals@lists.php.net Date: Sat, 12 Jul 2003 20:03:38 +0100 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200307122003.38874.hudzilla@php.net> Subject: __get() and __set() in PHP 5 From: hudzilla@php.net (Paul Hudson) All, I've been poking around with these two functions while testing the build from CVS, and am not sure how they're supposed to work. From what I can gather, they are only called when changing a variable that wasn't in the class definition. I say that because I took the example script from http://uk.php.net/zend-engine-2.php and stripped it down to this: n = 1; $foo->z++; $foo->z++; ?> That script outputs nothing, despite reading and writing to z twice, and writing to n once. If you comment out the "public $n;" and "public $z;" lines, you get the following output: Setting [n] to 1 Getting [z] Setting [z] to 1 Getting [z] Setting [z] to 1 ... which is what I was expecting. Are __get() and __set(), then, only supposed to work with non-declared variables, or am I doing something wrong? Thanks, --Paul