1. 17
    Write multiple conditions to execute alternate PHP code
    3m 24s

Write multiple conditions to execute alternate PHP code

InstructorMark Shust

Share this video with your friends

Send Tweet

You'll eventually need to run a block of PHP code that executes if your "if" statement is false. In this event, you will use an "else"| clause.

~ a year ago
<?php if ($hasPost ===3) echo 'Post equal to 3 Exist.'; elseif($hasPost) echo 'Post exist greater than 3'; else echo 'No post exist'; ?>

is there a syntax update this one seem to work for me

Mark Shustinstructor
~ a year ago

This is shorthand syntax and is still valid PHP code. I recommend the bracketed syntax though as it has defined start and end points for each block of code, which makes the code more readable and easier to understand. I’d use shorthand syntax very sparingly, if at all.

~ a year ago

Thanks for sharing @Mark