Re: POST variable and PHP 7

From: Date: Wed, 29 Apr 2020 20:26:53 +0000
Subject: Re: POST variable and PHP 7
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-327118@lists.php.net to get a copy of this message
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@quillandmouse.com> 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 >

« previous php.general (#327118) next »