|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34194 Real properties in PHP classes
Submitted: 2005-08-19 16:41 UTC Modified: 2010-12-22 03:52 UTC
Avg. Score:4.6 ± 0.7
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: stochnagara at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5CVS-2005-08-19 (CVS) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
47 + 50 = ?
Subscribe to this entry?

 [2005-08-19 16:41 UTC] stochnagara at hotmail dot com
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:

Reproduce 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";

Expected result:
Foo bar

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-22 03:52 UTC]
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-22 03:52 UTC]
This request is covered by this RFC:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 03:03:37 2021 UTC