PHP echo在HTML之后保持在同一行 (£; )
此代码在新行上输出回声。我不希望出现这种情况,也不希望PHP在英镑符号之后启动,因此解决方案是什么PHP echo在HTML之后保持在同一行 (£; ),php,html,Php,Html,此代码在新行上输出回声。我不希望出现这种情况,也不希望PHP在英镑符号之后启动,因此解决方案是什么 我知道我可以通过在英镑符号之后和PHP标记之前添加HTML注释来实现这一点,但我想知道是否有更好的解决方案?为什么不能这样做 (<?php _e( 'Up to', 'test' ); ?> £ <?php $current_price = get_field( 'price_details_price_b', 'option' ); $exchange_ra
我知道我可以通过在英镑符号之后和PHP标记之前添加HTML注释来实现这一点,但我想知道是否有更好的解决方案?为什么不能这样做
(<?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;
?>)
(£为什么你不能这么做
(<?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;
?>)
(£可能先进行提取和计算:
(<?php _e( 'Up to', 'test' ); echo '£';
$current_price = get_field( 'price_details_price_b', 'option' );
然后在适当的情况下组合输出:
<?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);
?>
()
可能先进行抓取和计算:
(<?php _e( 'Up to', 'test' ); echo '£';
$current_price = get_field( 'price_details_price_b', 'option' );
然后在适当的情况下组合输出:
<?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;
如果PHP代码之外有新行,它们当然会作为新行输出。PHP对此无能为力。更常见的做法是获取您需要的数据首先eed,然后显示它。在计算价格之前,应该忽略英镑,然后echo'£;。$uk_price;
如果PHP代码之外有新行,它们当然会作为新行输出。PHP对此无能为力。