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

Single and Double Quotes

Оглавление

PHP allows you to use single or double quotes when defining strings. With WordPress, it's recommended to always use single quotes when possible. This makes it easy to use double quotes within the string without escaping them. The following is an example of echoing a link that has double quotes within the single‐quoted string:

<?php echo '<a href="https://example.com">Visit Example.com</a>';

You can also use double quotes when you need to insert a variable within the string. The following example grabs the current site's name and echoes a message with the variable:

<?php $pdev_site_name = get_bloginfo( 'name', 'display' ); echo "You are viewing {$pdev_site_name}.";

Professional WordPress Plugin Development

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