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
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:
MUST BE VALID
Solve the problem:
5 + 22 = ?
Subscribe to this entry?

 
 [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 19:01:32 2024 UTC