|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-05-29 11:14 UTC] chedong at yeah dot net
following code runs properly in php3 but failed at line 3 in php4
<?php
class test {
var $test = $PHP_SELF;
var $test1 = "ok";
function show_test()
{
echo $this->test;
echo $this->test1;
}
}
$testing = new test;
$testing->show_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.............
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 22:00:01 2025 UTC |
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; } }