(<?php _e( 'Up to', 'test' ); ?> £
<?php $current_price = get_field( 'price_details_price_b', 'option' );
$exchange_rate = get_field( 'price_details_exchange_rate', 'option' );
$uk_price = ($current_price * $exchange_rate);
echo $uk_price;
?>)
This code outputs the echo on a new line. I don't want this to occur and I don't want the PHP to start after the pound symbol, therefore what is the solution?
I know I can do this by adding HTML comment <!-- -->
after the pound symbol and before the PHP tag but wondered if there was a better solution?
Maybe do your fetching and calculating first:
<?php
$current_price = get_field( 'price_details_price_b', 'option' );
$exchange_rate = get_field( 'price_details_exchange_rate', 'option' );
$uk_price = ($current_price * $exchange_rate);
?>
And then output combined, where appropriate:
(<?php
_e( 'Up to', 'test' );
echo '£' . $uk_price;
?>)
Why couldn't you just do
(<?php _e( 'Up to', 'test' ); ?> £ <?php
$current_price = get_field( 'price_details_price_b', 'option' );
? Or not drop out of PHP mode in the first place?
(<?php _e( 'Up to', 'test' ); echo '£';
$current_price = get_field( 'price_details_price_b', 'option' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.