Home > Mobile >  asking for 2 issets as an function param in PHP
asking for 2 issets as an function param in PHP

Time:04-12

Hey guys quick Question.

Is this code below correct?

if (isset($_POST['testSendDe']) || isset($_POST["testSendEn"])) {"function"}

can i ask for 2 issets as an param?

CodePudding user response:

You can use null coalescing operator for this to make it one liner like below:

<?php

echo "<td>" . (($_POST['vorname'] ?? false) || ($_POST["firstName"] ?? "")) . "</td>";

Update:

If you wish to print some text of your own than what is present in those keys, you could do the below:

<?php

echo "<td>" . (($_POST['vorname'] ?? ($_POST["firstName"] ?? false)) ? "printing because either of them is set" : "printing because none of them is set") . "</td>";
  • Related