Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > "const" in PHP
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 3rd July 00:32
jean-philippe.benard-renexter
External User
 
Posts: 1
Default "const" in PHP



Hi,

With the ArcaAttributes class definition (see below) I've an arror
when trying to use one of the constants of this class as this :

echo ArcaAttributes::ATT_EMPLOYEENUMBER;

Parse error: parse error, expecting `'('' in
/dtpdev01/dtp/racine-web/arca_test/test.php on line 117

It seams waiting only functions when using "::".

Could someone help me ? How to define constant in a cless without the
"define()" function ? (I don't want to use the define function because it
makes the constant defined everywhere).

Many thanks in advance !


class ArcaAttributes {
/**
* Liste des attributs à retourner
* @var array
*/
var $attributes = array();
var $set = false;

const ATT_EMPLOYEENUMBER = 'uid';
const ATT_CN = 'cn';
const ATT_MAIL = 'mail';
const ATT_POSTALADDRESS = 'postofficebox';
const ATT_TELEPHONENUMBER = 'telephonenumber';

const ATT_DEFAULT_PERSON_ATTRIBUTES = array(
ArcaAttributes::ATT_EMPLOYEENUMBER,
ArcaAttributes::ATT_CN,
ArcaAttributes::ATT_MAIL,
ArcaAttributes::ATT_POSTALADDRESS,
ArcaAttributes::ATT_TELEPHONENUMBER
);

function ArcaAttributes($clearList = false) {
if ($clearList)
$this->attributes = array();
else
$this->setDefaultAttributes();
}

function addAttribute($attrib) {
array_push($this->attributes, $attrib);
}

function clearAttributes($clearList = false) {
if ($clearList) {
$this->set = false;
$this->attributes = array();
}
else
$this->setDefaultAttributes();
}

function setDefaultAttributes() {
$this->set = true;
$this->attributes =
ArcaAttributes::ATT_DEFAULT_PERSON_ATTRIBUTES;
}

function is_set() {
if ($this->set === true)
return true;
else
return false;
}
}
<<<

(o_ BENARD Jean-Philippe - Consultant STERIA Infogérance
(o_ (o_ //\ RENAULT DTSI/ODPS/R@D * ALO * API : MLB 02C 1 14
(/)_ (\)_ V_/_ 2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666