From: [EMAIL PROTECTED]
Operating system: Win NT 4 Server
PHP version: 4.2.3
PHP Bug Type: Class/Object related
Bug description: Object property association broken
The following example doesn't work, but is listed in the documentation as
being valid:
<?php
class DateTime {
function DateTime() {
// empty constructor
}
function now() {
return date("Y-m-d H:i:s");
}
}
class Report {
var $_dt = new DateTime();
// more properties ...
function Report() {
// initialization code ...
}
function generateReport() {
$dateTime = $_dt->now();
// more code ...
}
// more methods ...
}
$rep = new Report();
?>
This returns the error:
Parse error: parse error, unexpected T_NEW in test.php on line 14
I have tried this with other classes and basically it seems that you
cannot default a class property to an instatiated class unless through the
constructor. This is contrary to the documentation.
--
Edit bug report at http://bugs.php.net/?id=20531&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20531&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20531&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20531&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20531&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20531&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20531&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20531&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20531&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20531&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20531&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20531&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20531&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20531&r=isapi