jeudi 8 octobre 2015

Can't figure out how to translate an to a PHP boolean

I have an <input type="checkbox" name="showonhmpg" /> which I want to become a PHP true/false value depending on whether it is checked. For some reason, I've noticed that if it's checked then $_POST['showonhmpg'] equals 0 and if it's not checked then $_POST['showonhmpg'] equals null. Is this expected behavior? It's awkward because then I have to write something like

$showonhmpg = $_POST['showonhmpg'] ? true : false; 




Aucun commentaire:

Enregistrer un commentaire