ID: 9414
Updated by: torben
Reported By: [EMAIL PROTECTED]
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] [EMAIL PROTECTED]
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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to