php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33087 properties
Submitted: 2005-05-20 18:36 UTC Modified: 2006-04-03 13:42 UTC
From: glashtin at sbcglobal dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5CVS-2005-05-20 (dev) OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: glashtin at sbcglobal dot net
New email:
PHP Version: OS:

 

 [2005-05-20 18:36 UTC] glashtin at sbcglobal dot net
Description:
------------
I would like to see properties added to php like most other OOP languages have.  The way I see it being used is

class MyClass
{
    private $FMyVar1
    private $FMyVar2;

    property $MyVar1 read=$FMyVar1 write=$FMyVar1;
    property $MyVar2 read=$this->MyFunction(); write=$FMyVar2;


    private function MyFunction()
    {
        if ( $something )
            $this->FMyVar2 = 'This';
        else
            $this->FMyVar2 = 'That';

        return $this->FMyVar2;
    }
}

Or something like that.

I know there are work arounds but I would still like to see properties add so that I can clean up my code.  In my opinion it looks better to use

echo $MyClass->MyVar2;

than

echo $MyClass->MyFunction();

just a suggestion.

Thanks


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 13:42 UTC] tony2001@php.net
Use __get()/__set().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 17:01:35 2025 UTC