Example WS and php tags

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@129419 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2003-05-30 16:36:18 +00:00
parent 3b0bf2bff9
commit 1ea6d0f6ce
4 changed files with 62 additions and 54 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<refentry id="function.money-format">
<refnamediv>
<refname>money_format</refname>
@ -218,44 +218,44 @@
<![CDATA[
<?php
$number = 1234.56;
$number = 1234.56;
// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number)."\n";
// USD 1,234.56
// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number)."\n";
// USD 1,234.56
// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number)."\n";
// L. 1.234,56
// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number)."\n";
// L. 1.234,56
// Using a negative number
$number = -1234.5672;
// Using a negative number
$number = -1234.5672;
// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number)."\n";
// ($ 1,234.57)
// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number)."\n";
// ($ 1,234.57)
// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number)."\n";
// ($********1,234.57)
// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number)."\n";
// ($********1,234.57)
// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, withouth grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56)."\n";
// DEM 1234,56****
// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, withouth grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56)."\n";
// DEM 1234,56****
// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56)."\n";
// The final value is GBP 1,234.56 (after a 10% discount)
// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56)."\n";
// The final value is GBP 1,234.56 (after a 10% discount)
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.number-format">
<refnamediv>
@ -58,21 +58,21 @@
<![CDATA[
<?php
$number = 1234.56;
$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,234
// english notation (default)
$english_format_number = number_format($number);
// 1,234
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
$number = 1234.5678;
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.strtok">
<refnamediv>
@ -24,6 +24,7 @@
<title><function>strtok</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$string = "This is\tan example\nstring";
/* Use tab and newline as tokenizing characters as well */
$tok = strtok($string," \n\t");
@ -31,6 +32,7 @@ while ($tok) {
echo "Word=$tok<br>";
$tok = strtok(" \n\t");
}
?>
]]>
</programlisting>
</example>
@ -53,14 +55,16 @@ while ($tok) {
<title>Old <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
<?php
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
/* Output:
string(0) ""
string(9) "something"
*/
?>
]]>
</programlisting>
</example>
@ -68,14 +72,16 @@ while ($tok) {
<title>New <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
<?php
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
/* Output:
string(9) "something"
bool(false)
*/
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.strtr">
<refnamediv>
@ -33,7 +33,9 @@
<title><function>strtr</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$addr = strtr($addr, "äåö", "aao");
?>
]]>
</programlisting>
</example>
@ -52,8 +54,8 @@ $addr = strtr($addr, "
<programlisting role="php">
<![CDATA[
<?php
$trans = array("hello" => "hi", "hi" => "hello");
echo strtr("hi all, I said hello", $trans);
$trans = array("hello" => "hi", "hi" => "hello");
echo strtr("hi all, I said hello", $trans);
?>
]]>
</programlisting>