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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

History

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