Skip to content

Commit

Permalink
Clarify the output of example code about undefined variable usage (#2679
Browse files Browse the repository at this point in the history
)

Accessing undefined variables generate an E_WARNING since PHP 8 (and will result in error exceptions being thrown in PHP 9).

Co-authored-by: George Peter Banyard <[email protected]>
  • Loading branch information
onuryilmazer and Girgias authored Aug 14, 2023
1 parent 16389a7 commit 00e8d1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion language/variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ test();
</informalexample>

<simpara>
This script will not produce any output because the echo statement
This script will generate an undefined variable <constant>E_WARNING</constant>
(or a <constant>E_NOTICE</constant> prior to PHP 8.0.0)
diagnostic. However, if the
<link linkend="ini.display-errors">display_errors</link> INI setting is set to hide
such diagnostics then nothing at all will be outputted.
This is because the echo statement
refers to a local version of the <varname>$a</varname> variable,
and it has not been assigned a value within this scope. You may
notice that this is a little bit different from the C language in
Expand Down

0 comments on commit 00e8d1f

Please sign in to comment.