Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5804

Re: const var, self:: or static::

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: const var, self:: or static::
Date 2012-05-02 17:25 +0200
Message-ID <a0d1vjF3qmU1@mid.uni-berlin.de> (permalink)
References <a0ce19Fb48U1@mid.individual.net>

Show all headers | View raw


Am 02.05.2012 11:45, schrieb Simon:
> If I have something like...
> 
> //
> class MyClass
> {
>  const MY_CONST =  10;
> 
>  ...
> }
> //
> 
> Inside the class, is it 'better' to use self::MY_CONST or static::MY_CONST?
> 
> I say 'better' because it works in both cases.
> 
> Or is it just a personal choice.

It works with static:: but it is not documented. Maybe a PHP4 compatibility thing.

I would not use it. Documented are self::$var parent::$var and Classname::$var

/Str.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

const var, self:: or static:: Simon <bad@example.com> - 2012-05-02 11:45 +0200
  Re: const var, self:: or static:: Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-02 07:13 -0400
  Re: const var, self:: or static:: "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-02 17:25 +0200
    Re: const var, self:: or static:: Michael Fesser <netizen@gmx.de> - 2012-05-02 19:55 +0200

csiph-web