|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4658 global parameters in class
Submitted: 2000-05-29 11:14 UTC Modified: 2000-05-29 16:00 UTC
From: chedong at yeah dot net Assigned:
Status: Closed Package: Other
PHP Version: 4.0.0 Release OS: freebsd
Private report: No CVE-ID: None
 [2000-05-29 11:14 UTC] chedong at yeah dot net
following code runs properly in php3 but failed at line 3 in php4

class test {	
	var $test = $PHP_SELF;
	var $test1 = "ok";
	function show_test()
		echo $this->test;
		echo $this->test1;
$testing = new test;
the error shows:
Parse error: parse error in /home/chedong/public_html/test2.php on line 3
i wrote this for i find some classes i wrote runs properly in php3 but failed when it under php4.............


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-29 16:00 UTC] sterling at cvs dot php dot net
Quoth the incompatibilities list:

  Static variable and class member initializers only accept scalar values (in PHP
  3.0 they accepted any valid expression). The impact should be small, since 
  initializers with anything but a simple static value rarely make sense. 

A workaround is to create a constructor that sets the value of $test:

class test
  var $test;
  function test ()
    $this->test = $PHP_SELF;
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:28 2024 UTC