PHP 4.0 Bug #9414 Updated: date() returns error when included in an object
| From: | torben@php.net | Date: | Fri, 23 Feb 2001 00:03:19 +0000 |
| Subject: | PHP 4.0 Bug #9414 Updated: date() returns error when included in an object | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-47305@lists.php.net to get a copy of this message | ||
ID: 9414
Updated by: torben
Reported By: eric@lcb.uoregon.edu
Old-Status: Open
Status: Closed
Bug Type: Date/time related
Assigned To:
Comments:
Not a bug; from the manual (http://www.php.net/manual/en/language.oop.php):
Note: In PHP 4, only constant initializers for var variables are allowed. Use
constructors for non-constant initializers.
So you could have 'var $dateTest = "foo";', or 'var $dateTest =
201029;', but not
anything which would depend upon runtime evaluation.
What this means is that you should have something like this instead:
<?php
class showDate {
var $dateTest;
function showDate() {
$this->dateTest = date("Y-m-d");
}
}
?>
This could probably benefit from a better example in the manual, though.
Cheers,
Torben
Previous Comments:
---------------------------------------------------------------------------
[2001-02-22 18:47:21] eric@lcb.uoregon.edu
When I try to use the date() inside of a class in
PHP4.0.4pl1 an error gets returned.
Example:
<?
class showDate {
var $dateTest = date("Y-m-d");
}
$object1 = new showDate;
echo $object1->dateTest;
?>
Returns the following error:
Parse error: parse error, expecting
','' or ';'' in
/path/to/file/date_test.php on line 7
My php.ini has expose tags = off, and an include path,
otherwise it's pretty much out of the box php.ini
I did a static build with the following config:
./configure --with-apache=../apache
--with-mysql=/path/to/mysql --with-openssl=/path/to/ssl
--with-zlib --with-xml --enable-bcmath
Thanks,
eric
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9414&edit=2