php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #20437 static $m=1|2;
Submitted: 2002-11-14 21:45 UTC Modified: 2003-08-15 20:33 UTC
From: rrobin at greenapple dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.1 OS: Any
Private report: No CVE-ID: None
 [2002-11-14 21:45 UTC] rrobin at greenapple dot com
it seems that i cannot do
static $m=1|2|4;

getting rid of the static would compile it.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-15 01:03 UTC] derick@php.net
From 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). 
 [2002-11-15 17:55 UTC] rrobin at greenapple dot com
i am not in the class,
the whole file contains only
<?php
static $m=1|2;
?>
 [2002-11-15 17:57 UTC] derick@php.net
hmm, not so sure if this is expected or a bug, Andi?

Derick
 [2002-11-15 18:19 UTC] msopacua@php.net
Any expression or function call, doesn't work with a static declaration. It's documented through the user notes at:
http://www.php.net/manual/en/language.variables.scope.php
posting by "tomek at pluton dot pl".

It does IMO deserve proper documentation, because downloadable docs, don't contain the user notes.
 [2003-08-15 20:33 UTC] ali@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

I added a note with an example to the docs, which should 
clarify the behaviour of static vars when values are assigned 
to them. 
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of ali
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=ffc7a9431dc7af50d3ba379eb5209bb91489537b
Log: fixed #20437 by adding a note
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 21:01:26 2024 UTC