Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 64

Brace Style

Оглавление

Any multiline statement in PHP should use brackets to contain the entire code block. Following this brace style will keep your code clear and less prone to errors. See the next code snippet for the appropriate usage of braces:

<?php if ( $condition_a ) { action_a(); } elseif ( $condition_b || $condition_c ) { action_b(); action_c(); }

Even if there's only a single line within each block, make sure to enclose it too. Forgoing the braces for single‐line statements is usually a bad idea and may result in bugs when you add extra code in the future.

Professional WordPress Plugin Development

Подняться наверх