lundi 5 février 2018

Running same code in different conditions in PHP

As you see, almost same code (3,4,5,6. and 8,9,10,11. lines) is run after condition1 and else. How can I simplify this? I don't want to use functions because if I did, I would have to define all the database things again.

<?php
if (condition1 is true) {
  if ($a > $b*0.5) {
  echo "successful";} 
  else {
  echo "missed";}
else {
  if ($a > $b) {
  echo "successful";} 
  else {
  echo "missed";}
?>

Aucun commentaire:

Enregistrer un commentaire