function.money-format.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 384 行 · 第 1/2 页
HTML
384 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Formats a number as a currency string</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.metaphone.html">metaphone</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.nl-langinfo.html">nl_langinfo</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.money-format" class="refentry"> <div class="refnamediv"> <h1 class="refname">money_format</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">money_format</span> — <span class="dc-title">Formats a number as a currency string</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>money_format</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$format</tt></span> , <span class="methodparam"><span class="type">float</span> <tt class="parameter">$number</tt></span> )</div> <p class="para rdfs-comment"> <b>money_format()</b> returns a formatted version of <i><tt class="parameter">number</tt></i>. This function wraps the C library function <b>strfmon()</b>, with the difference that this implementation converts only one number at a time. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">format</tt></i></span> <dd> <p class="para"> The format specification consists of the following sequence: <ul class="itemizedlist"> <li class="listitem"><p class="para">a <i>%</i> character</p></li> <li class="listitem"><p class="para">optional flags</p></li> <li class="listitem"><p class="para">optional field width</p></li> <li class="listitem"><p class="para">optional left precision</p></li> <li class="listitem"><p class="para">optional right precision</p></li> <li class="listitem"><p class="para">a required conversion character</p></li> </ul> </p> <p class="formalpara"> <h5 class="title">Flags</h5> <p class="para"> One or more of the optional flags below can be used: <dl> <dt> <span class="term"><i>=</i><span class="replaceable">f</span></span> <dd> <p class="para"> The character <i>=</i> followed by a (single byte) character <span class="replaceable">f</span> to be used as the numeric fill character. The default fill character is space. </p> </dd> </dt> <dt> <span class="term"><i>^</i></span> <dd> <p class="para"> Disable the use of grouping characters (as defined by the current locale). </p> </dd> </dt> <dt> <span class="term"><i>+</i> or <i>(</i></span> <dd> <p class="para"> Specify the formatting style for positive and negative numbers. If <i>+</i> is used, the locale's equivalent for <i>+</i> and <i>-</i> will be used. If <i>(</i> is used, negative amounts are enclosed in parenthesis. If no specification is given, the default is <i>+</i>. </p> </dd> </dt> <dt> <span class="term"><i>!</i></span> <dd> <p class="para"> Suppress the currency symbol from the output string. </p> </dd> </dt> <dt> <span class="term"><i>-</i></span> <dd> <p class="para"> If present, it will make all fields left-justified (padded to the right), as opposed to the default which is for the fields to be right-justified (padded to the left). </p> </dd> </dt> </dl> </p> </p> <p class="formalpara"> <h5 class="title">Field width</h5> <p class="para"> <dl> <dt> <span class="term"><span class="replaceable">w</span></span> <dd> <p class="para"> A decimal digit string specifying a minimum field width. Field will be right-justified unless the flag <i>-</i> is used. Default value is 0 (zero). </p> </dd> </dt> </dl> </p> </p> <p class="formalpara"> <h5 class="title">Left precision</h5> <p class="para"> <dl> <dt> <span class="term"><i>#</i><span class="replaceable">n</span></span> <dd> <p class="para"> The maximum number of digits (<span class="replaceable">n</span>) expected to the left of the decimal character (e.g. the decimal point). It is used usually to keep formatted output aligned in the same columns, using the fill character if the number of digits is less than <span class="replaceable">n</span>. If the number of actual digits is bigger than <span class="replaceable">n</span>, then this specification is ignored. </p> <p class="para"> If grouping has not been suppressed using the <i>^</i> flag, grouping separators will be inserted before the fill characters (if any) are added. Grouping separators will not be
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?