Re: "const" in PHP
| From: | Marek Kilimajer | Date: | Thu, 16 Oct 2003 11:55:34 +0000 |
| Subject: | Re: "const" in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-166285@lists.php.net to get a copy of this message | ||
Are you using php5? const is not available in php4 or less.
BENARD Jean-philippe wrote:
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-BRETONNEUXTél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10