jeroen Sun Aug 5 18:49:38 2001 EDT Modified files: /phpdoc/en/functions strings.xml Log: Fix examles (whitespace between funcname and parameters), and a few entities
Index: phpdoc/en/functions/strings.xml diff -u phpdoc/en/functions/strings.xml:1.101 phpdoc/en/functions/strings.xml:1.102 --- phpdoc/en/functions/strings.xml:1.101 Sun Aug 5 06:51:46 2001 +++ phpdoc/en/functions/strings.xml Sun Aug 5 18:49:38 2001 @@ -1,5 +1,5 @@ <?xml encoding="iso-8859-1"?> -<!-- $Revision: 1.101 $ --> +<!-- $Revision: 1.102 $ --> <reference id="ref.strings"> <title>String functions</title> <titleabbrev>Strings</titleabbrev> @@ -22,7 +22,7 @@ <refentry id="function.addcslashes"> <refnamediv> - <refname>AddCSlashes</refname> + <refname>addcslashes</refname> <refpurpose>Quote string with slashes in a C style</refpurpose> </refnamediv> <refsect1> @@ -55,7 +55,7 @@ <example> <title><function>addcslashes</function> example</title> <programlisting role="php"> -$escaped = addcslashes ($not_escaped, "\0..\37!@\177..\377"); +$escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); </programlisting> </example> </para> @@ -101,7 +101,7 @@ <refentry id="function.addslashes"> <refnamediv> - <refname>AddSlashes</refname> + <refname>addslashes</refname> <refpurpose>Quote string with slashes</refpurpose> </refnamediv> <refsect1> @@ -169,7 +169,7 @@ <example> <title><function>chop</function> example</title> <programlisting role="php"> -$trimmed = chop ($line); +$trimmed = chop($line); </programlisting> </example> </para> @@ -206,11 +206,11 @@ <example> <title><function>chr</function> example</title> <programlisting role="php"> -$str .= chr (27); /* add an escape character at the end of $str */ +$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); +$str = sprintf("The string ends in escape: %c", 27); </programlisting> </example> This function complements <function>ord</function>. See also @@ -252,7 +252,7 @@ <programlisting role="php"> # format $data using RFC 2045 semantics -$new_string = chunk_split (base64_encode($data)); +$new_string = chunk_split(base64_encode($data)); </programlisting> </example> This function is significantly faster than @@ -560,7 +560,7 @@ // However, the following examples will work: ($some_var) ? print('true'): print('false'); // print is a function -echo ($some_var) ? 'true': 'false'; // changing the statement around +echo $some_var ? 'true': 'false'; // changing the statement around ?> </programlisting> </example> @@ -623,7 +623,7 @@ <title><function>explode</function> example</title> <programlisting role="php"> $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; -$pieces = explode (" ", $pizza); +$pieces = explode(" ", $pizza); </programlisting> </example> </para> @@ -681,9 +681,9 @@ <example> <title>Translation Table Example</title> <programlisting role="php"> -$trans = get_html_translation_table (HTML_ENTITIES); +$trans = get_html_translation_table(HTML_ENTITIES); $str = "Hallo & <Frau> & Krämer"; -$encoded = strtr ($str, $trans); +$encoded = strtr($str, $trans); </programlisting> </example> The <literal>$encoded</literal> variable will now contain: "Hallo @@ -696,8 +696,8 @@ the direction of the translation. <informalexample> <programlisting role="php"> -$trans = array_flip ($trans); -$original = strtr ($str, $trans); +$trans = array_flip($trans); +$original = strtr($str, $trans); </programlisting> </informalexample> The content of <literal>$original</literal> would be: "Hallo & @@ -970,7 +970,7 @@ <example> <title><function>implode</function> example</title> <programlisting role="php"> -$colon_separated = implode (":", $array); +$colon_separated = implode(":", $array); </programlisting> </example> </para> @@ -1465,7 +1465,7 @@ <example> <title><function>ord</function> example</title> <programlisting role="php"> -if (ord ($str) == 10) { +if (ord($str) == 10) { echo "The first character of \$str is a line feed.\n"; } </programlisting> @@ -1636,7 +1636,7 @@ <example> <title><function>rtrim</function> example</title> <programlisting role="php"> -$trimmed = rtrim ($line); +$trimmed = rtrim($line); </programlisting> </example> </para> @@ -1841,12 +1841,12 @@ <example> <title>Soundex Examples</title> <programlisting role="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'; +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> </para> @@ -2027,7 +2027,7 @@ <example> <title><function>sprintf</function>: zero-padded integers</title> <programlisting role="php"> -$isodate = sprintf ("%04d-%02d-%02d", $year, $month, $day); +$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day); </programlisting> </example> <example> @@ -2037,7 +2037,7 @@ $money2 = 54.35; $money = $money1 + $money2; // echo $money will output "123.1"; -$formatted = sprintf ("%01.2f", $money); +$formatted = sprintf("%01.2f", $money); // echo $formatted will output "123.10" </programlisting> </example> @@ -2110,7 +2110,7 @@ <programlisting role="php"> $var1 = "Hello"; $var2 = "hello"; -if (!strcasecmp ($var1, $var2)) { +if (!strcasecmp($var1, $var2)) { echo '$var1 is equal to $var2 in a case-insensitive string comparison'; } </programlisting> @@ -2421,7 +2421,7 @@ below: <informalexample> <programlisting> -$arr1 = $arr2 = array ("img12.png","img10.png","img2.png","img1.png"); +$arr1 = $arr2 = array("img12.png","img10.png","img2.png","img1.png"); echo "Standard string comparison\n"; usort($arr1,"strcmp"); print_r($arr1); @@ -2655,14 +2655,14 @@ <informalexample> <programlisting role="php"> // in PHP 4.0b3 and newer: -$pos = strpos ($mystring, "b"); +$pos = strpos($mystring, "b"); if ($pos === false) { // note: three equal signs // not found... } // in versions older than 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { +$pos = strpos($mystring, "b"); +if (is_string($pos) && !$pos) { // not found... } </programlisting> @@ -2724,11 +2724,11 @@ <title><function>strrchr</function> example</title> <programlisting role="php"> // get last directory in $PATH -$dir = substr (strrchr ($PATH, ":"), 1); +$dir = substr(strrchr($PATH, ":"), 1); // get everything after last newline $text = "Line 1\nLine 2\nLine 3"; -$last = substr (strrchr ($text, 10), 1 ); +$last = substr(strrchr($text, 10), 1 ); </programlisting> </example> </para> @@ -2761,7 +2761,7 @@ <example> <title><function>str_repeat</function> example</title> <programlisting role="php"> -echo str_repeat ("-=", 10); +echo str_repeat("-=", 10); </programlisting> </example> <para> @@ -2828,14 +2828,14 @@ <informalexample> <programlisting role="php"> // in PHP 4.0b3 and newer: -$pos = strrpos ($mystring, "b"); +$pos = strrpos($mystring, "b"); if ($pos === false) { // note: three equal signs // not found... } // in versions older than 4.0b3: -$pos = strrpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { +$pos = strrpos($mystring, "b"); +if (is_string($pos) && !$pos) { // not found... } </programlisting> @@ -2880,7 +2880,7 @@ The line of code: <informalexample> <programlisting role="php"> -$var = strspn ("42 is the answer, what is the question ...", "1234567890"); +$var = strspn("42 is the answer, what is the question ...", "1234567890"); </programlisting> </informalexample> will assign 2 to <varname>$var</varname>, because the string "42" will @@ -2930,7 +2930,7 @@ <title><function>strstr</function> example</title> <programlisting role="php"> $email = '[EMAIL PROTECTED]'; -$domain = strstr ($email, '@'); +$domain = strstr($email, '@'); print $domain; // prints @designmultimedia.com </programlisting> </example> @@ -2966,10 +2966,10 @@ <title><function>strtok</function> example</title> <programlisting role="php"> $string = "This is an example string"; -$tok = strtok ($string," "); +$tok = strtok($string," "); while ($tok) { echo "Word=$tok<br>"; - $tok = strtok (" "); + $tok = strtok(" "); } </programlisting> </example> @@ -3015,7 +3015,7 @@ <para> Note that 'alphabetic' is determined by the current locale. This means that in i.e. the default "C" locale, characters such as - umlaut-A (Ä) will not be converted. + umlaut-A (Ä) will not be converted. </para> <example> <title><function>strtolower</function> example</title> @@ -3058,7 +3058,7 @@ <title><function>strtoupper</function> example</title> <programlisting role="php"> $str = "Mary Had A Little Lamb and She LOVED It So"; -$str = strtoupper ($str); +$str = strtoupper($str); print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO </programlisting> </example> @@ -3118,7 +3118,7 @@ <example> <title><function>str_replace</function> example</title> <programlisting role="php"> -$bodytag = str_replace ("%body%", "black", "<body text=%body%>"); +$bodytag = str_replace("%body%", "black", "<body text=%body%>"); </programlisting> </example> </para> @@ -3183,7 +3183,7 @@ Examples: <informalexample> <programlisting role="php"> -$trans = array ("hello" => "hi", "hi" => "hello"); +$trans = array("hello" => "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans) . "\n"; </programlisting> </informalexample> @@ -3235,8 +3235,8 @@ Examples: <informalexample> <programlisting role="php"> -$rest = substr ("abcdef", 1); // returns "bcdef" -$rest = substr ("abcdef", 1, 3); // returns "bcd" +$rest = substr("abcdef", 1); // returns "bcdef" +$rest = substr("abcdef", 1, 3); // returns "bcd" </programlisting> </informalexample> </para> @@ -3248,9 +3248,9 @@ Examples: <informalexample> <programlisting role="php"> -$rest = substr ("abcdef", -1); // returns "f" -$rest = substr ("abcdef", -2); // returns "ef" -$rest = substr ("abcdef", -3, 1); // returns "d" +$rest = substr("abcdef", -1); // returns "f" +$rest = substr("abcdef", -2); // returns "ef" +$rest = substr("abcdef", -3, 1); // returns "d" </programlisting> </informalexample> </para> @@ -3274,7 +3274,7 @@ Examples: <informalexample> <programlisting role="php"> -$rest = substr ("abcdef", 1, -1); // returns "bcde" +$rest = substr("abcdef", 1, -1); // returns "bcde" </programlisting> </informalexample> </para> @@ -3370,18 +3370,18 @@ echo "Original: $var<hr>\n"; /* These two examples replace all of $var with 'bob'. */ -echo substr_replace ($var, 'bob', 0) . "<br>\n"; -echo substr_replace ($var, 'bob', 0, strlen ($var)) . "<br>\n"; +echo substr_replace($var, 'bob', 0) . "<br>\n"; +echo substr_replace($var, 'bob', 0, strlen($var)) . "<br>\n"; /* Insert 'bob' right at the beginning of $var. */ -echo substr_replace ($var, 'bob', 0, 0) . "<br>\n"; +echo substr_replace($var, 'bob', 0, 0) . "<br>\n"; /* These next two replace 'MNRPQR' in $var with 'bob'. */ -echo substr_replace ($var, 'bob', 10, -1) . "<br>\n"; -echo substr_replace ($var, 'bob', -7, -1) . "<br>\n"; +echo substr_replace($var, 'bob', 10, -1) . "<br>\n"; +echo substr_replace($var, 'bob', -7, -1) . "<br>\n"; /* Delete 'MNRPQR' from $var. */ -echo substr_replace ($var, '', 10, -1) . "<br>\n"; +echo substr_replace($var, '', 10, -1) . "<br>\n"; ?> </programlisting> </example> @@ -3447,12 +3447,12 @@ <para> Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a - (ä) will not be converted. + (ä) will not be converted. <example> <title><function>ucfirst</function> example</title> <programlisting role="php"> $text = 'mary had a little lamb and she loved it so.'; -$text = ucfirst ($text); // $text is now Mary had a little lamb +$text = ucfirst($text); // $text is now Mary had a little lamb // and she loved it so. </programlisting> </example> @@ -3625,4 +3625,5 @@ sgml-local-catalogs:nil sgml-local-ecat-files:nil End: +vim: ts=1 sw=1 et syntax=sgml -->