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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 23:01:28 2025 UTC