Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18609 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53166 invoked by uid 1010); 31 Aug 2005 14:51:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53150 invoked from network); 31 Aug 2005 14:51:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2005 14:51:15 -0000 X-Host-Fingerprint: 212.238.144.71 korving.demon.nl Received: from ([212.238.144.71:15845] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 3C/86-15098-2E3C5134 for ; Wed, 31 Aug 2005 10:51:14 -0400 Message-ID: <3C.86.15098.2E3C5134@pb1.pair.com> To: internals@lists.php.net References: Date: Wed, 31 Aug 2005 16:50:30 +0200 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 212.238.144.71 Subject: Re: Real properties in PHP From: r.korving@xit.nl ("Ron Korving") I very much like your idea and syntax. I come from a Delphi background (when it comes to properties) and I must say I like your solution. It's easy and effective. Yes, it can be done with __set() and __get(), but it sure is uglier when you have a wide and constant range of properties. +1 (with 0 karma anyway). Ron "Marian Kostadinov" wrote in message news:bec76cf9050825032978cd308d@mail.gmail.com... I wrote about real properies a few days ago but no one seems to be interested in it. I think that it would be nice to have real properties present in PHP. I mean properties like those in C# but a little more flexible by allowing getter and setter to have different visibility. See sample code below: Sample code: --------------- class person { public $firstName, $lastName; public getter fullName { // may also have () return "{$this->firstName} {$this->lastName}"; } public setter fullName ($value) { // may also not have ($value) but a special var. list ($this->firstName, $this->lastName) = explode (' ', $value, 2); } } $p = new person; $p->fullName = "Foo bar"; echo $p->firstName . "\n"; echo $p->lastName . "\n"; echo $p->fullName . "\n"; Sample result: ---------------- Foo bar Foo bar