<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Notice: Undefined variable /  Undefined index / Undefined offset </p>
<p>This is a bug that causes a lot of problems,<br />no one knows if it's on purpose or if someone forgot to change something or made a typo.</p>
<p><a href="https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined#answer-4261200">https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined#answer-4261200</a></p>
<p>From the vast wisdom of the<span> </span><a href="http://php.net/manual/en/language.variables.basics.php#example-112" rel="noreferrer">PHP Manual</a>:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<p>Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major<span> </span><a href="http://www.php.net/manual/en/security.globals.php" rel="noreferrer">security risk</a><span> </span>with<span> </span><a href="http://www.php.net/manual/en/ini.core.php#ini.register-globals" rel="noreferrer">register_globals</a><span> </span>turned on.<span> </span><a href="http://www.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-notice" rel="noreferrer">E_NOTICE</a><span> </span>level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array.<span> </span><a href="http://www.php.net/manual/en/function.isset.php" rel="noreferrer">isset()</a><span> </span>language construct can be used to detect if a variable has been already initialized. Additionally and more ideal is the solution of<span> </span><a href="http://php.net/manual/en/function.empty.php" rel="noreferrer">empty()</a><span> </span>since it does not generate a warning or error message if the variable is not initialized.</p>
</blockquote>
<div id="signature">--<br />
<div class="pre global">
<div style="padding: 0px 5px;">
<div style="font-family: Tahoma, Geneva, sans-serif; font-size: 12.5px; color: #01374d; font-weight: 200;">Z poważaniem / Kind regards</div>
<div style="padding-top: 7px; font-family: Tahoma, Geneva, sans-serif; font-size: 21.67px; color: #01374d; font-weight: bold;">Mariusz Krzaczkowski</div>
</div>
</div>
</div>
<p id="reply-intro">W dniu 2021-05-05 17:36, Alan Lord napisał(a):</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap;">Interesting.</span><br /><br />That seems like good/valid Warning - it should encourage the declaration of variables at the start of each routine.<br /><br />Maybe for a variable variable it might not make sense but those aren't that common it seems to me?<br /><br /><span style="white-space: nowrap;">Nice to hear from you Joe. Hope all's well.</span><br /><br />Cheers<br /><br />Al<br /><br /><br /><span style="white-space: nowrap;">On 05/05/2021 16:24, Joe Bordes wrote:</span>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><span style="white-space: nowrap;">Sadly, PHP warning system doesn't work that way:</span><br /><br /><span style="white-space: nowrap;">----</span><br /><br /><span style="white-space: nowrap;"><?php</span><br /><span style="white-space: nowrap;">error_reporting(-1);</span><br /><span style="white-space: nowrap;">ini_set('display_errors', 1);</span><br /><br /><span style="white-space: nowrap;">if ($nothere) {</span><br /><span style="white-space: nowrap;">     echo "it is here";</span><br /><span style="white-space: nowrap;">} else {</span><br /><span style="white-space: nowrap;">     echo "it isn't here";</span><br /><span style="white-space: nowrap;">}</span><br /><span style="white-space: nowrap;">-----</span><br /><br />result<br /><br /><span style="white-space: nowrap;">-----</span><br /><br /><span style="white-space: nowrap;">joe@linuxmint:/var/www/coreBOSTest$ php k.php</span><br />PHP Notice:  Undefined variable: nothere in /var/www/coreBOSTest/k.php on line 5<br /><span style="white-space: nowrap;">PHP Stack trace:</span><br /><span style="white-space: nowrap;">PHP   1. {main}() /var/www/coreBOSTest/k.php:0</span><br /><br /><span style="white-space: nowrap;">Notice: Undefined variable: nothere in /var/www/coreBOSTest/k.php on line 5</span><br /><br /><span style="white-space: nowrap;">Call Stack:</span><br /><span style="white-space: nowrap;">     0.0001     393600   1. {main}() /var/www/coreBOSTest/k.php:0</span><br /><br /><span style="white-space: nowrap;">it isn't here</span><br /><br /><span style="white-space: nowrap;">------</span><br /><br /><br />so you get the warning if the variable is not defined which is what you are trying to avoid<br /><br /></blockquote>
<br /><br /><br />_______________________________________________<br /><span style="white-space: nowrap;"><a href="http://www.vtiger.com/" target="_blank" rel="noopener noreferrer">http://www.vtiger.com/</a></span></div>
</blockquote>
</body></html>