mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
fixed #20437 by adding a note
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@137922 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
38754fb943
commit
ffc7a9431d
1 changed files with 28 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.68 $ -->
|
||||
<!-- $Revision: 1.69 $ -->
|
||||
<chapter id="language.variables">
|
||||
<title>Variables</title>
|
||||
|
||||
|
@ -552,6 +552,33 @@ function Test()
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Static variables maybe declared as seen in the examples above.
|
||||
Trying to assign values to these variables which are the
|
||||
result of expressions will cause a parse error.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Declaring static variables</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo(){
|
||||
static $int = 0; // correct
|
||||
static $int = 1+2; // wrong (as it is an expression)
|
||||
static $int = sqrt(121); // wrong (as it is an expression too)
|
||||
|
||||
$int++;
|
||||
echo $int;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</note>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.scope.references">
|
||||
|
|
Loading…
Reference in a new issue