Added php tags (<?php ?>) to examples.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@129420 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2003-05-30 16:47:59 +00:00
parent 1ea6d0f6ce
commit bcecf5d323
26 changed files with 100 additions and 29 deletions

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.addcslashes">
<refnamediv>
@ -35,7 +35,9 @@
<title><function>addcslashes</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
?>
]]>
</programlisting>
</example>
@ -47,11 +49,13 @@ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
echo addcslashes('foo[ ]', 'A..z');
// output: \f\o\o\[ \]
// All upper and lower-case letters will be escaped
// ... but so will the [\]^_` and any tabs, line
// feeds, carriage returns, etc.
?>
]]>
</programlisting>
</informalexample>
@ -63,8 +67,10 @@ echo addcslashes('foo[ ]', 'A..z');
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
echo addcslashes("zoo['.']", 'z..A');
// output: \zoo['\.']
?>
]]>
</programlisting>
</informalexample>

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.chr">
<refnamediv>
@ -19,11 +19,13 @@
<title><function>chr</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$str .= chr(27); /* add an escape character at the end of $str */
/* Often this is more useful */
$str = sprintf("The string ends in escape: %c", 27);
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.chunk-split">
<refnamediv>
@ -25,9 +25,10 @@
<title><function>chunk_split</function> example</title>
<programlisting role="php">
<![CDATA[
# format $data using RFC 2045 semantics
<?php
// format $data using RFC 2045 semantics
$new_string = chunk_split(base64_encode($data));
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.fprintf">
<refnamediv>
<refname>fprintf</refname>
@ -134,7 +134,9 @@
<title><function>sprintf</function>: zero-padded integers</title>
<programlisting role="php">
<![CDATA[
<?php
$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);
?>
]]>
</programlisting>
</example>
@ -142,12 +144,14 @@ $isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);
<title><function>sprintf</function>: formatting currency</title>
<programlisting role="php">
<![CDATA[
<?php
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$formatted = sprintf("%01.2f", $money);
// echo $formatted will output "123.10"
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.get-html-translation-table">
<refnamediv>
@ -39,9 +39,11 @@
<title>Translation Table Example</title>
<programlisting role="php">
<![CDATA[
<?php
$trans = get_html_translation_table(HTML_ENTITIES);
$str = "Hallo & <Frau> & Krämer";
$encoded = strtr($str, $trans);
?>
]]>
</programlisting>
</example>
@ -55,8 +57,10 @@ $encoded = strtr($str, $trans);
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$trans = array_flip($trans);
$original = strtr($encoded, $trans);
?>
]]>
</programlisting>
</informalexample>

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.68 -->
<refentry id="function.localeconv">
<refnamediv>
@ -174,6 +174,7 @@
<title><function>localeconv</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
setlocale(LC_ALL, "en_US");
$locale_info = localeconv();
@ -198,6 +199,7 @@ echo "n_sep_by_space: {$locale_info["n_sep_by_space"]}\n";
echo "p_sign_posn: {$locale_info["p_sign_posn"]}\n";
echo "n_sign_posn: {$locale_info["n_sign_posn"]}\n";
echo "</PRE>\n";
?>
]]>
</programlisting>
</example>

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.ord">
<refnamediv>
@ -20,9 +20,11 @@
<title><function>ord</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
if (ord($str) == 10) {
echo "The first character of \$str is a line feed.\n";
}
?>
]]>
</programlisting>
</example>

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.soundex">
<refnamediv>
@ -32,12 +32,14 @@
<title>Soundex Examples</title>
<programlisting role="php">
<![CDATA[
<?php
soundex("Euler") == soundex("Ellery") == 'E460';
soundex("Gauss") == soundex("Ghosh") == 'G200';
soundex("Hilbert") == soundex("Heilbronn") == 'H416';
soundex("Knuth") == soundex("Kant") == 'K530';
soundex("Lloyd") == soundex("Ladd") == 'L300';
soundex("Lukasiewicz") == soundex("Lissajous") == 'L222';
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.sprintf">
<refnamediv>
@ -125,8 +125,10 @@
<title>Argument swapping</title>
<programlisting role="php">
<![CDATA[
<?php
$format = "There are %d monkeys in the %s";
printf($format,$num,$location);
?>
]]>
</programlisting>
</example>
@ -138,8 +140,10 @@ printf($format,$num,$location);
<title>Argument swapping</title>
<programlisting role="php">
<![CDATA[
<?php
$format = "The %s contains %d monkeys";
printf($format,$num,$location);
?>
]]>
</programlisting>
</example>
@ -152,8 +156,10 @@ printf($format,$num,$location);
<title>Argument swapping</title>
<programlisting role="php">
<![CDATA[
<?php
$format = "The %2\$s contains %1\$d monkeys";
printf($format,$num,$location);
?>
]]>
</programlisting>
</example>
@ -163,9 +169,11 @@ printf($format,$num,$location);
<title>Argument swapping</title>
<programlisting role="php">
<![CDATA[
<?php
$format = "The %2\$s contains %1\$d monkeys.
That's a nice %2\$s full of %1\$d monkeys.";
printf($format, $num, $location);
?>
]]>
</programlisting>
</example>
@ -184,7 +192,9 @@ printf($format, $num, $location);
<title><function>sprintf</function>: zero-padded integers</title>
<programlisting role="php">
<![CDATA[
<?php
$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);
?>
]]>
</programlisting>
</example>
@ -192,12 +202,14 @@ $isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);
<title><function>sprintf</function>: formatting currency</title>
<programlisting role="php">
<![CDATA[
<?php
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$formatted = sprintf("%01.2f", $money);
// echo $formatted will output "123.10"
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.33 -->
<refentry id="function.sscanf">
<refnamediv>
@ -34,12 +34,14 @@
<title><function>sscanf</function> Example</title>
<programlisting role="php">
<![CDATA[
<?php
// getting the serial number
$serial = sscanf("SN/2350001","SN/%d");
// and the date of manufacturing
$mandate = "January 01 2000";
list($month, $day, $year) = sscanf($mandate,"%s %d %d");
echo "Item $serial was manufactured on: $year-".substr($month,0,3)."-$day\n";
?>
]]>
</programlisting>
</example>
@ -50,6 +52,7 @@ echo "Item $serial was manufactured on: $year-".substr($month,0,3)."-$day\n";
<title><function>sscanf</function> - using optional parameters</title>
<programlisting role="php">
<![CDATA[
<?php
// get author info and generate DocBook entry
$auth = "24\tLewis Carroll";
$n = sscanf($auth,"%d\t%s %s", &$id, &$first, &$last);
@ -57,6 +60,7 @@ echo "<author id='$id'>
<firstname>$first</firstname>
<surname>$last</surname>
</author>\n";
?>
]]>
</programlisting>
</example>

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.str-ireplace">
<refnamediv>
@ -49,7 +49,9 @@
<title><function>str_ireplace</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$bodytag = str_replace("%body%", "black", "<body text=%BODY%>");
?>
]]>
</programlisting>
</example>

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.26 -->
<refentry id="function.str-pad">
<refnamediv>
@ -41,10 +41,12 @@
<title><function>str_pad</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$input = "Alien";
print str_pad($input, 10); // produces "Alien "
print str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien"
print str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___"
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.str-repeat">
<refnamediv>
@ -24,7 +24,9 @@
<title><function>str_repeat</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
echo str_repeat("-=", 10);
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.str-replace">
<refnamediv>
@ -53,7 +53,9 @@
<title><function>str_replace</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$bodytag = str_replace("%body%", "black", "<body text=%body%>");
?>
]]>
</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.strcasecmp">
<refnamediv>
@ -24,11 +24,13 @@
<title><function>strcasecmp</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$var1 = "Hello";
$var2 = "hello";
if (strcasecmp($var1, $var2) == 0) {
echo '$var1 is equal to $var2 in a case-insensitive string comparison';
}
?>
]]>
</programlisting>
</example>

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.strip-tags">
<refnamediv>
@ -35,7 +35,9 @@
<title><function>strip_tags</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$string = strip_tags($string, '<a><b><i><u>');
?>
]]>
</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.38 -->
<refentry id="function.strnatcmp">
<refnamediv>
@ -25,6 +25,7 @@
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$arr1 = $arr2 = array("img12.png","img10.png","img2.png","img1.png");
echo "Standard string comparison\n";
usort($arr1,"strcmp");
@ -32,6 +33,7 @@ print_r($arr1);
echo "\nNatural order string comparison\n";
usort($arr2,"strnatcmp");
print_r($arr2);
?>
]]>
</programlisting>
</informalexample>

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.strrchr">
<refnamediv>
@ -35,12 +35,14 @@
<title><function>strrchr</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// get last directory in $PATH
$dir = substr(strrchr($PATH, ":"), 1);
// get everything after last newline
$text = "Line 1\nLine 2\nLine 3";
$last = substr(strrchr($text, 10), 1 );
?>
]]>
</programlisting>
</example>

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.strrev">
<refnamediv>
@ -18,7 +18,7 @@
<title>Reversing a string with <function>strrev</function></title>
<programlisting role="php">
<![CDATA[
<php
<?php
echo strrev("Hello world!"); // outputs "!dlrow olleH"
?>
]]>

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.strspn">
<refnamediv>
@ -25,7 +25,9 @@
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$var = strspn("42 is the answer, what is the question ...", "1234567890");
?>
]]>
</programlisting>
</informalexample>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.strstr">
<refnamediv>
@ -36,9 +36,11 @@
<title><function>strstr</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$email = 'user@example.com';
$domain = strstr($email, '@');
print $domain; // prints @example.com
?>
]]>
</programlisting>
</example>

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.strtolower">
<refnamediv>
@ -25,9 +25,11 @@
<title><function>strtolower</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
print $str; # Prints mary had a little lamb and she loved it so
?>
]]>
</programlisting>
</example>

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.strtoupper">
<refnamediv>
@ -25,9 +25,11 @@
<title><function>strtoupper</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
]]>
</programlisting>
</example>

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.ucfirst">
<refnamediv>
@ -25,12 +25,14 @@
<title><function>ucfirst</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
]]>
</programlisting>
</example>

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.ucwords">
<refnamediv>
@ -22,12 +22,14 @@
<title><function>ucwords</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.142 -->
<refentry id="function.wordwrap">
<refnamediv>
@ -46,10 +46,12 @@
<title><function>wordwrap</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap( $text, 20 );
echo "$newtext\n";
?>
]]>
</programlisting>
<para>
@ -69,10 +71,12 @@ lazy dog.
<title><function>wordwrap</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap( $text, 8, "\n", 1);
echo "$newtext\n";
?>
]]>
</programlisting>
<para>