You are here: Re: bug or feature? (OO design/languages) « PHP Programming Language « IT news, forums, messages
Re: bug or feature? (OO design/languages)

Posted by Janwillem Borleffs on 09/18/05 01:13

www.douglassdavis.com wrote:
> class MyClass2
> {
> var $x = 2;
> static $y = $x; // error
> }
>

$x does not exist until instantiation, so you should assign $y in the
constructor:

class MyClass2 {
var $x = 2;
static $y;

function __construct() {
$this->y = $this->x;
}
}

The same principle applies to the previous MyClass code, where $this->x
should be replaced by self::$x.

> class MyClass3
> {
> const a = array(1,2); // error
> }

From http://www.php.net/manual/en/language.constants.php:

"Only scalar data (boolean, integer, float and string) can be contained in
constants."


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация