Answer the question
In order to leave comments, you need to log in
Why is the alternative syntax of php control structures sometimes used in layout?
Why is the alternative syntax of php control structures sometimes used in layout? For example,
if (..):
....
endif;
if (..) {
....
}
Answer the question
In order to leave comments, you need to log in
well, because it's more readable
<?php if ($test == 1): ?>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<?php endif ?>
<?php if ($test == 1) {
echo "<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>
<div>some text</div>";
}
?>
Because the code looks neat and the automatic formatting works great. endif, endfor, endforeach perfectly indicate which block was closed, but just the bracket is sometimes unclear and you have to scroll through the code and look.
Sometimes? Lol. This is how it should always be. In general, it is better to use template engines
Everything that is not forbidden will be done at some point. Plus, I suspect they don't use syntax highlighting, and many of them are parenthesized.
In the company, this is decided by the development council and the style guide is added. Do not use, for example, the ternary operator, goto, type definition only through is_*, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question