lundi 10 septembre 2018

Multi Conditional PHP IF statement only if variable has value

I have the following if statement, I want to return TRUE if example = sidebar, date start < now, and date end > now. It works as is but the problem is if one of the values doesn't exist, the statement is false.

How can I change the statement to only add conditions if each variable ($position,$date_start, $date_end) isset ?

<?php if ($position == "sidebar" && $date_start < strtotime('now') && $date_end > strtotime('now')): ?>

Aucun commentaire:

Enregistrer un commentaire