PHP elseif statement problem
-
This works
<?php if( get_field('divergence', 10681) ) { <div>Some text</div> } else echo '<div>' . "Some alternative text" . '</div>'; ?>
But I want to use this method so the HTML isn’t echoed
<?php if( get_field('divergence', 10681) ): ?> <div>Some text</div> <?php elseif; ?> <div>Some alternative text</div> <?php endif; ?>
I can’t get the else statement to work, only this works so far
<?php if( get_field('divergence', 10681) ): ?> <div>Some text</div> <?php endif; ?>
I thought avoiding the echo method seems more appropriate when there’s a reasonable amount of HTML tags to use, as the above demo is simplified. Just want to place the tags as normal.
Thanks,
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘PHP elseif statement problem’ is closed to new replies.