Re: Fechas y classes
| From: | Gabi | Date: | Wed, 13 Aug 2003 21:40:58 +0000 |
| Subject: | Re: Fechas y classes | ||
| References: | 1 2 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-39381@lists.php.net to get a copy of this message | ||
Esque no he entendido nada de lo que pone en inglés se muy poko, no es mi
fuerte. Llevo como 4 o 5 años sin aprobar inglés.
Siento mi incultura.
Salu2 y Asias
----- Original Message -----
From: "Àngel Fenoy" <afenoy@wol.es>
To: <lista@phpes.com>
Sent: Wednesday, August 13, 2003 1:19 PM
Subject: Re: [PHP-ES] Fechas y classes
Dimecres 13 Agost 2003 12:41, Gabi dixit:
> Hola.
>
> Se me produce el siguiente error:
> Parse error: parse error, expecting
','' or
> ';'' in
> /home/webcindario/gabi/fechas.php on line 4
>
> Pueden verlo en:
> http://gabi.webcindario.com/fechas.php
>
> Y tengo el siguienet codigo:
>
> <?
> class fechas
> {
> var $h=date('H');
> var $minu=date('i');
> var $s=date('s');
> var $d=date('d');
Del manual de PHP (http://www.php.net/manual/en/language.oop.php):
--------------------------------------
Note: In PHP 4, only constant initializers for var variables are allowed.
To initialize variables with non-constant values, you need an initialization
function which is called automatically when an object is being constructed
from the class. Such a function is called a constructor (see below).
<?php
/* None of these will work in PHP 4. */
class Cart
{
var $todays_date = date("Y-m-d");
var $name = $firstname;
var $owner = 'Fred ' . 'Jones';
var $items = array("VCR", "TV");
}
/* This is how it should be done. */
class Cart
{
var $todays_date;
var $name;
var $owner;
var $items;
function Cart()
{
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}
?>
----------------------------------------------------------
El manual en castellano está obsoleto, y no consta la anterior anotación. Es
conveniente consultar SIEMPRE el manual en inglés.
Saludos
Àngel
---------------------------------------------------------------------
Archivo On-line: http://www.phpes.com/
via news: news://news.phpes.com/
Manual PHP en español: http://www.php.net/manual/es/
Para dar de baja la suscripción, mande un mensaje a:
lista-unsubscribe@phpes.com