php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #2599 class variables
Submitted: 1999-10-25 04:21 UTC Modified: 2001-02-10 14:00 UTC
From: jymil at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0 OS: linux 2.1
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: jymil at hotmail dot com
New email:
PHP Version: OS:

 

 [1999-10-25 04:21 UTC] jymil at hotmail dot com
Variable declarations in classes can't refer to other
variables in that class, only value assigments are
allowed. The following example does not work:

class test
{ var $testvar = "this is a test";
  var $test2 = $this->testvar;
}

Would be nice if such things were possible.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 13:51 UTC] jimw@php.net
i believe this is by design. i'll let zeev close it if so.
 [2001-02-10 14:00 UTC] hholzgra@php.net
sorry, only constant values may be used 
for initial assignments to member variables in php 4

do it in a constructor instead

see http://www.php.net/manual/en/x45905.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 14:01:34 2024 UTC