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

Space Usage

Оглавление

When building your plugin, you should always add spaces after commas and on each side of logical, comparison, and other operators. The following code snippet shows several basic PHP examples and how they should be spaced:

<?php if ( $foo === 'bar' ) { // Do something. } elseif ( ! $foo ) { // Do something else. } foreach ( $foo as $bar ) { // Do something. } function pdev_function( $param_a = 'foo', $param_b = 'bar' ) { // Do something. } $foo = range( 10, 100, 10 );

Using this spacing technique keeps your code clean and makes it easy to read. The rule of thumb is to always be judicious with spacing. Or, when in doubt, use a space.

Professional WordPress Plugin Development

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