0

So my question is:

If I don't write anything in an input

<input type="text" name="test">

in a simple form with post method, when I receive the $_POST array in my action url, the $_POST["test"] exists as empty string ($_POST["test"] => "").

So I can't use null coalesce because $var = $_POST["test"] ?? 'default'; because it is always $var = ""; (as is normal).

Any way to solve this problem?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
franlol
  • 51
  • 7

1 Answers1

1

for Only check if a PARTICULAR Key is available in post data

if (isset($_POST['test']) )
{
    $textData = '+text'.$_POST['test'];
    echo $textData;
}
Mohit Kumar
  • 952
  • 2
  • 7
  • 18
  • Golly, why didn't I post that answer? Did you see that I posted a duplicate link? Did you check that before you offered your answer? StackOverflow doesn't _need_ more questions/pages. It needs unique questions/pages. Please help this community by filtering out the duplicates. – mickmackusa Jun 29 '18 at 03:27
  • And now you are getting upvotes -- which will encourage you to post answers to duplicate questions. – mickmackusa Jun 29 '18 at 03:29
  • You can actually start doing the right thing, right now, right here. There are millions of legitimate questions to answer here. Try to earn your rep from questions that are unique. – mickmackusa Jun 29 '18 at 03:30