Re: POST variable and PHP 7

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Paul!

Are you sure its an error or a notice? I can see  you getting a notice if the item isn't set but not an error.

Also this is expected behavior for a long while, it could have been the case that error reporting on php5 didn't show notices by default when php7 does.

You can hide notices on php7 via error reporting, but I would not recommend it and instead check for the value before using.

On Wed, Apr 29, 2020 at 4:13 PM Paul M Foster <paulf@xxxxxxxxxxxxxxxxx> wrote:
Folks:

Consider a reentrant form. This is a form a user might be returned to if
they omit a field or enter some illegal value. It might look like this:

<input type="text" name="pizza" value="<?php echo $_POST['pizza']; ?>" >

The first time through, under PHP 7, this will error out, because there
is no 'pizza' index for the $_POST array. The $_POST array is empty.

Seems like I used to use this exact idiom under PHP 5, and it worked,
but under PHP 7 it doesn't.

Am I mis-remembering? If not, is there some common way around this under
PHP 7?

Paul

--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux