dimanche 30 avril 2017

PHP if statement inside HTML

I am checking if the value stored in my variable is equal to 0 or 1.
Depending on the value, I want to display some text inside my html form.
The value that I have inside $details['status'] is 0 of type int.

When I print_r() outside of the if-else structure, the result is 0.
However, if I print_r() inside the if statements, I get nothing back.

<form class="form-horizontal" action="/MVC/teacher/becomeTeacher" method="post">
    <?php print_r($details['status'])?> <!-- Gives me 0 -->

    <?php if($details['status'] === 1): ?>
        This will show if the status value is 1.
    <? elseif ($details['status'] === 0): ?>
        Otherwise this will show.
    <?php endif; ?>
</form>

Aucun commentaire:

Enregistrer un commentaire