cvs: phpdoc /en/language/oop5 constants.xml

From: Date: Mon, 19 Jul 2004 04:52:41 +0000
Subject: cvs: phpdoc /en/language/oop5 constants.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969361976@lists.php.net to get a copy of this message
curt Mon Jul 19 00:52:41 2004 EDT Modified files: /phpdoc/en/language/oop5 constants.xml Log: The Constsnts documentation for oop5 http://cvs.php.net/diff.php/phpdoc/en/language/oop5/constants.xml?r1=1.1&r2=1.2&ty=u Index: phpdoc/en/language/oop5/constants.xml diff -u phpdoc/en/language/oop5/constants.xml:1.1 phpdoc/en/language/oop5/constants.xml:1.2 --- phpdoc/en/language/oop5/constants.xml:1.1 Sun Jul 11 08:33:25 2004 +++ phpdoc/en/language/oop5/constants.xml Mon Jul 19 00:52:41 2004 @@ -1,11 +1,38 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 id="language.oop5.constants"> <title>Object Constants</title> <para> - . + It is possible to define constant values on a per-class basis remaining + the same and unchangeable. Constant's differ from normal variables + in that you dont use the <varname>$</varname> symbol to declare or use + them. Like <xref linkend="language.oop5.static"/> members, constant + values can not be accessed with a variable that is an instance of the + object. </para> + <example> + <title>Defining and using a constant</title> + <programlisting role="php"> +<![CDATA[ +<?php +class MyClass { + const constant = 'constant value'; + + function showConstant() { + echo self::constant . "\n"; + } +} + +echo MyClass::constant . "\n"; + +$class = new MyClass(); +$class->showConstant(); +/* echo $class::constant; is not allowed */ +?> +]]> + </programlisting> + </example> </sect1>

« previous php.doc (#969361976) next »