php 如何加粗变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11681435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 01:51:51  来源:igfitidea点击:

How to bold a variable?

php

提问by space ranger

How can I have text within a php variable be bold??

如何让 php 变量中的文本变粗?

function show_balance_header ($balance, $currency)
{
    (string)$display_output = null;
    $display_output = fees_main::display_amount(abs($balance), $currency, true);
    return $display_output;
}

I want to bold $balance. Is there an easy way or do I need to edit display_amount?

我要大胆$balance。有没有简单的方法或者我需要编辑display_amount

I've tried doing this:

我试过这样做:

"<b>".$balance"</b>"but this did not get the correct variable,

"<b>".$balance"</b>"但这没有得到正确的变量,

thanks in advance!!

提前致谢!!

采纳答案by space ranger

answer is to edit the inner function display_amount using Raeki's suggestion, for future questions, i think you must edit the inner-most function as only editing function show_balance_header did not get the correct variable

答案是使用 Raeki 的建议编辑内部函数 display_amount,对于以后的问题,我认为您必须编辑最内部的函数,因为只有编辑函数 show_balance_header 没有得到正确的变量

回答by Raekye

Needs to be "<b>" . $balance . "</b>". Concatenate <b>to $balanceand concatenate again to </b>

需要"<b>" . $balance . "</b>"。连接<b>$balance并再次连接到</b>



Edit: Assuming this does the printing/formatting: fees_main::display_amount(abs($balance)

编辑:假设这会进行打印/格式化:fees_main::display_amount(abs($balance)

You want fees_main::display_amount('<b>' . abs($balance) . '</b>', $currency, true). abs($balance) gets the absolute value as a number, and the concatenation (explained above) automatically casts them to strings. The rest of the parameters are passed the same way (unmodified, unbolded).

你要fees_main::display_amount('<b>' . abs($balance) . '</b>', $currency, true)。abs($balance) 以数字形式获取绝对值,并且连接(如上所述)会自动将它们转换为字符串。其余参数以相同方式传递(未修改、未加粗)。

(string)$display_output = null;is unnecessary

(string)$display_output = null;没有必要

回答by Ricardo Alvaro Lohmann

On your element html, example:

在您的元素 html 上,例如:

<p> text <?php echo "<b>{$balance}</b>"; ?> text</p>