Under the
Don't use uninitialized variables part of CG we instruct users about how to avoid warnings caused by uninitialized variables, but we don't really say how we intend to initialize them.
I'd suggest to adjust this part in the way like this:
Code: Select all
<h4>Don't use uninitialized variables.</h4>
For phpBB3, we intend to use a higher level of run-time error reporting. This will mean that the use of an uninitialized variable will be reported as a warning. These warnings can be avoided by two ways.
Initialize variables before use where it is possible, examples:
<p class="bad">// Wrong </p>
<div class="codebox"><pre>
foreach ($array as $key => $value)
{
$foo[] = $key;
$bar = $value;
}
</pre></div>
<p class="good">// Right </p>
<div class="codebox"><pre>
$foo = array();
$bar = '';
foreach ($array as $key => $value)
{
$foo[] = $key;
$bar = $value;
}
</pre></div>
Use the built-in isset() function to check whether a variable has been set - but preferably the variable is always existing. For checking if an array has a key set this can come in handy though, examples:
...and keep the further text as it follows.
Also could be applied to 3.0.x CG.