php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15682 Bitwise concatenation of constants in class variables
Submitted: 2002-02-22 17:14 UTC Modified: 2002-02-22 18:43 UTC
From: s-m-k at gmx dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.1.1 OS: WinXP
Private report: No CVE-ID: None
 [2002-02-22 17:14 UTC] s-m-k at gmx dot net
class foo {

$var bar = E_ALL & ~E_NOTICE;

}

Obviously a scalar value (assigning a single value works perfectly), but the following appears when it comes to execution:

Parse error: parse error, expecting "," or ";"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-22 17:15 UTC] s-m-k at gmx dot net
class foo {

var $bar = E_ALL & ~E_NOTICE;

}

Obviously a scalar value (assigning a single value works perfectly), but
the following appears when it comes to execution:

Parse error: parse error, expecting "," or ";"
 [2002-02-22 18:43 UTC] derick@php.net
Not a bug. You can only use static assignments here:

From the manual @ 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).

regards,
Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 19:01:31 2024 UTC