Re: Undefined variable [message #181244 is a reply to message #181235] |
Wed, 24 April 2013 10:20 |
Christoph Becker
Messages: 91 Registered: June 2012
Karma:
|
Member |
|
|
Question Boy wrote:
> For instance, I have a block of code, such as:
>
> if ($iBookedBy=="Other") {
> echo '<option selected value="Other">Other</option>';
> } else {
> echo '<option value="Other">Other</option>';
> }
>
> which the log file reports as:
>
> PHP Notice: Undefined variable: iBookedBy
You should investigate, why $iBookeyBy is undefined. It is always
preferable to initialize a variable explicitely before you use it. This
is particularly important for PHP due to the dangerous register_globals
option (which was fortunately removed since PHP 5.4). If this is
enabled (what should never be), the code may be vulnerable. Checking
for isset($iBookeyBy) won't help in this case.
--
Christoph M. Becker
|
|
|