lundi 12 février 2018

Assign and use variable inside of PHP if statement

I am wondering whether it is possible to use a variable inside of the same if statement that it is assigned in using PHP.

For example:

if ($start = strtotime($_POST['date']) && $start <= time()) {
    $error = 'You must choose a date in the future.';
}

That code does not appear to be working for me, but I don't see why it shouldn't since I know the variable can be assigned like that, and it would make sense for me for the following variable to then be able to access it.

Aucun commentaire:

Enregistrer un commentaire