vendredi 29 juillet 2016

PHP If with or, then do something, reference specific true clause

For example:

<?php
varONE = "I am not empty";
unset($varTWO);
unset($varTHREE);

if(empty($varONE || $varTWO || $varTHREE)) {
  echo "TRUE vars are empty"
 }

//the long way round:
if(empty($varONE)) { echo "varONE is empty" }
if(empty($varTWO)) { echo "varTWO is empty" }
if(empty($varTHREE)) { echo "varTHREE is empty" }

?>

So the result would tell me that specifically varTWO and varTHREE are empty. Ultimately, the goal is to check an entire forms worth of input, make sure that all 12 inputs have some value input.

Aucun commentaire:

Enregistrer un commentaire