📄 intl.examples.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Examples</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="intl.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.intl.html">intl Functions</a></div> <div class="up"><a href="book.intl.html">intl</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Examples</h1> <div id="intl.examples.basic" class="section"> <h2 class="title">Basic usage of this extension</h2> <p class="para"> Each module provides two kind of APIs: a procedural one and an object oriented one. Both are actually identical and described in the corresponding document. </p> <blockquote><p><b class="note">Note</b>: All input strings must be in UTF-8 encoding. All output strings are also in UTF-8. <br /> </p></blockquote> <div class="example"> <p><b>Example #1 Example of using the procedural API</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$coll </span><span style="color: #007700">= </span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">collator_compare</span><span style="color: #007700">(</span><span style="color: #0000BB">$coll</span><span style="color: #007700">, </span><span style="color: #DD0000">"string#1"</span><span style="color: #007700">, </span><span style="color: #DD0000">"string#2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> <div class="example"> <p><b>Example #2 Example of using the object-oriented API</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$coll </span><span style="color: #007700">= new </span><span style="color: #0000BB">Collator</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$al </span><span style="color: #007700">= </span><span style="color: #0000BB">$coll</span><span style="color: #007700">-></span><span style="color: #0000BB">getLocale</span><span style="color: #007700">(</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">ACTUAL_LOCALE</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Actual locale: $al\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$formatter </span><span style="color: #007700">= new </span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">, </span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">DECIMAL</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$formatter</span><span style="color: #007700">-></span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #0000BB">1234567</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </div> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intl.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.intl.html">intl Functions</a></div> <div class="up"><a href="book.intl.html">intl</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -