mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fix #37880 (members' default value)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@216628 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
8fb36c05ed
commit
1f6a127f33
1 changed files with 32 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
|
||||
<sect1 id="language.oop5.basic">
|
||||
<title>The Basics</title>
|
||||
|
@ -84,6 +84,37 @@ class SimpleClass
|
|||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
The default value must be a constant expression, not (for example) a
|
||||
variable, a class member or a function call.
|
||||
<example>
|
||||
<title>Class members' default value</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass
|
||||
{
|
||||
// invalid member declarations:
|
||||
public $var1 = 'hello '.'world';
|
||||
public $var2 = <<<EOD
|
||||
hello world
|
||||
EOD;
|
||||
public $var3 = 1+2;
|
||||
public $var4 = self::myStaticMethod();
|
||||
public $var5 = $myVar;
|
||||
|
||||
// valid member declarations:
|
||||
public $var6 = myConstant;
|
||||
public $var7 = self::classConstant;
|
||||
public $var8 = array(true, false);
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
There are some nice functions to handle classes and objects. You might want
|
||||
|
|
Loading…
Reference in a new issue