cvs: phpdoc /en/functions oracle.xml outcontrol.xml ovrimos.xml pcntl.xml pcre.xml pdf.xml pfpro.xml pgsql.xml printer.xml pspell.xml readline.xml
recode.xml regex.xml satellite.xml sesam.xml session.xml shmop.xml snmp.xml sockets.xml strings.xml swf.xml uodbc.xml url.xml var.xml wddx.xml xml.xml
xslt.xml yaz.xml zip.xml zlib.xml
| From: | Hartmut Holzgraefe | Date: | Wed, 21 Nov 2001 23:05:19 +0000 |
| Subject: | cvs: phpdoc /en/functions oracle.xml outcontrol.xml ovrimos.xml pcntl.xml pcre.xml pdf.xml pfpro.xml pgsql.xml printer.xml pspell.xml readline.xml recode.xml regex.xml satellite.xml sesam.xml session.xml shmop.xml snmp.xml sockets.xml strings.xml swf.xml uodbc.xml url.xml var.xml wddx.xml xml.xml xslt.xml yaz.xml zip.xml zlib.xml |
||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969339105@lists.php.net to get a copy of this message | ||
hholzgra Wed Nov 21 18:05:19 2001 EDT
Modified files:
/phpdoc/en/functions oracle.xml outcontrol.xml ovrimos.xml
pcntl.xml pcre.xml pdf.xml pfpro.xml pgsql.xml
printer.xml pspell.xml readline.xml recode.xml
regex.xml satellite.xml sesam.xml session.xml
shmop.xml snmp.xml sockets.xml strings.xml
swf.xml uodbc.xml url.xml var.xml wddx.xml
xml.xml xslt.xml yaz.xml zip.xml zlib.xml
Log:
last bunch of <programlisting>/CDATA changes
Index: phpdoc/en/functions/oracle.xml diff -u phpdoc/en/functions/oracle.xml:1.23 phpdoc/en/functions/oracle.xml:1.24 --- phpdoc/en/functions/oracle.xml:1.23 Mon Nov 12 11:39:45 2001 +++ phpdoc/en/functions/oracle.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.oracle"> <title>Oracle functions</title> <titleabbrev>Oracle</titleabbrev> @@ -43,15 +43,17 @@ values if available. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php ora_parse($curs, "declare tmp INTEGER; begin tmp := :in; :out := tmp; :x := 7.77; end;"); ora_bind($curs, "result", ":x", $len, 2); ora_bind($curs, "input", ":in", 5, 1); ora_bind($curs, "output", ":out", 5, 2); $input = 765; ora_exec($curs); -echo "Result: $result<BR>Out: $output<BR>In: $input"; +echo "Result: $result<BR>Out: $output<BR>In: $input"; ?> +]]> </programlisting> </informalexample> </para> @@ -414,12 +416,14 @@ <example> <title>Oracle fetch into array</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php array($results); -ora_fetch_into($cursor, &$results); +ora_fetch_into($cursor, &$results); echo $results[0]; echo $results[1]; ?> +]]> </programlisting> </example> Note that you need to fetch the array by reference. @@ -511,7 +515,7 @@ <informalexample> <programlisting role="php"> $conn = Ora_Logon("user<emphasis>@TNSNAME</emphasis>", "pass"); -</programlisting> + </programlisting> </informalexample> </para> <para> Index: phpdoc/en/functions/outcontrol.xml diff -u phpdoc/en/functions/outcontrol.xml:1.18 phpdoc/en/functions/outcontrol.xml:1.19 --- phpdoc/en/functions/outcontrol.xml:1.18 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/outcontrol.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.outcontrol"> <title>Output Control Functions</title> <titleabbrev>Output Control</titleabbrev> @@ -19,7 +19,8 @@ <example> <title>Output Control example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php ob_start(); echo "Hello\n"; @@ -28,7 +29,8 @@ ob_end_flush(); -?> +?> +]]> </programlisting> </example> </para> @@ -154,7 +156,8 @@ <example> <title>User defined callback function example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function callback($buffer) { @@ -165,30 +168,33 @@ ob_start("callback"); -?> +?> -<html> -<body> -<p>It's like comparing apples to oranges. -</body> -</html> +<html> +<body> +<p>It's like comparing apples to oranges. +</body> +</html> -<?php +<?php ob_end_flush(); -?> +?> +]]> </programlisting> </example> <para> Would produce: <informalexample> <programlisting role="php"> -<html> -<body> -<p>It's like comparing oranges to oranges. -</body> -</html> +<![CDATA[ +<html> +<body> +<p>It's like comparing oranges to oranges. +</body> +</html> +]]> </programlisting> </informalexample> </para> @@ -284,16 +290,18 @@ <example> <title><function>ob_gzhandler</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php ob_start("ob_gzhandler"); ?> -<html> -<body> -<p>This should be a compressed page. -</html> -</body> +<html> +<body> +<p>This should be a compressed page. +</html> +<body> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/ovrimos.xml diff -u phpdoc/en/functions/ovrimos.xml:1.12 phpdoc/en/functions/ovrimos.xml:1.13 --- phpdoc/en/functions/ovrimos.xml:1.12 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/ovrimos.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <reference id="ref.ovrimos"> <title>Ovrimos SQL functions</title> <titleabbrev>OvrimosSQL</titleabbrev> @@ -22,7 +22,8 @@ Connect to Ovrimos SQL Server and select from a system table </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password"); if ($conn != 0) { echo ("Connection ok!"); @@ -34,7 +35,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will just connect to SQL Server. @@ -72,7 +74,8 @@ <example> <title><function>ovrimos_connect</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -84,7 +87,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> The above example will connect to the database and print out the @@ -172,7 +176,8 @@ <example> <title>Connect to Ovrimos SQL Server and prepare a statement</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn=ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn!=0) { echo "Connection ok!"; @@ -192,7 +197,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will connect to Ovrimos SQL Server, prepare a statement and @@ -326,17 +332,18 @@ <example> <title>A fetch into example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn=ovrimos_connect ("neptune", "8001", "admin", "password"); if ($conn!=0) { echo "Connection ok!"; $res=ovrimos_exec ($conn,"select table_id, table_name from sys.tables"); if ($res != 0) { echo "Statement ok!"; - if (ovrimos_fetch_into ($res, &$row)) { + if (ovrimos_fetch_into ($res, &$row)) { list ($table_id, $table_name) = $row; echo "table_id=".$table_id.", table_name=".$table_name."\n"; - if (ovrimos_fetch_into ($res, &$row)) { + if (ovrimos_fetch_into ($res, &$row)) { list ($table_id, $table_name) = $row; echo "table_id=".$table_id.", table_name=".$table_name."\n"; } else { @@ -349,7 +356,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This example will fetch a row. @@ -389,7 +397,8 @@ <example> <title>A fetch row example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("remote.host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -414,7 +423,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will fetch a row and print the result. @@ -478,7 +488,8 @@ <example> <title>Prepare a statement, execute, and view the result</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -498,7 +509,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will execute an SQL statement and print the result in an @@ -508,7 +520,8 @@ <example> <title>Ovrimos_result_all with meta-information</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -518,7 +531,7 @@ echo "Statement ok! cursor=".ovrimos_cursor ($res)."\n"; $colnb = ovrimos_num_fields ($res); echo "Output columns=".$colnb."\n"; - for ($i=1; $i<=$colnb; $i++) { + for ($i=1; $i <= $colnb; $i++) { $name = ovrimos_field_name ($res, $i); $type = ovrimos_field_type ($res, $i); $len = ovrimos_field_len ($res, $i); @@ -529,7 +542,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> </para> @@ -537,7 +551,8 @@ <example> <title>ovrimos_result_all example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -549,7 +564,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/pcntl.xml diff -u phpdoc/en/functions/pcntl.xml:1.6 phpdoc/en/functions/pcntl.xml:1.7 --- phpdoc/en/functions/pcntl.xml:1.6 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/pcntl.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <reference id="ref.pcntl"> <title>Process Control Functions</title> <titleabbrev>PCNTL</titleabbrev> @@ -114,7 +114,8 @@ <example> <title>Process Control Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pid = pcntl_fork(); if ($pid == -1) { @@ -160,6 +161,7 @@ ?> +]]> </programlisting> </example> </sect1> @@ -195,7 +197,8 @@ <example> <title><function>pcntl_fork</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pid = pcntl_fork(); if ($pid == -1) { @@ -206,7 +209,8 @@ // we are the child } -?> +?> +]]> </programlisting> </example> <para> @@ -246,7 +250,8 @@ <example> <title><function>pcntl_signal</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // signal handler function function sig_handler($signo) { @@ -283,7 +288,8 @@ print "Done\n" -?> +?> +]]> </programlisting> </example> <para> Index: phpdoc/en/functions/pcre.xml diff -u phpdoc/en/functions/pcre.xml:1.62 phpdoc/en/functions/pcre.xml:1.63 --- phpdoc/en/functions/pcre.xml:1.62 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/pcre.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.62 $ --> +<!-- $Revision: 1.63 $ --> <reference id="ref.pcre"> <title>Regular Expression Functions (Perl-Compatible)</title> <titleabbrev>PCRE</titleabbrev> @@ -23,7 +23,7 @@ <example> <title>Examples of valid patterns</title> <itemizedlist> - <listitem><simpara>/<\/\w+>/</simpara></listitem> + <listitem><simpara>/<\/\w+>/</simpara></listitem> <listitem><simpara>|(\d{3})-\d+|Sm</simpara></listitem> <listitem><simpara>/^(?i)php[34]/</simpara></listitem> <listitem><simpara>{^\s+(\s+)?$}</simpara></listitem> @@ -102,17 +102,20 @@ <example> <title>Find the string of text "php"</title> <programlisting role="php"> +<![CDATA[ // the "i" after the pattern delimiter indicates a case-insensitive search if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) { print "A match was found."; } else { print "A match was not found."; } +]]> </programlisting> </example> <example> <title>find the word "web"</title> <programlisting role="php"> +<![CDATA[ // the \b in the pattern indicates a word boundary, so only the distinct // word "web" is matched, and not a word partial like "webbing" or "cobweb" if (preg_match ("/\bweb\b/i", "PHP is the web scripting language of choice.")) { @@ -125,11 +128,13 @@ } else { print "A match was not found."; } +]]> </programlisting> </example> <example> <title>Getting the domain name out of a URL</title> <programlisting role="php"> +<![CDATA[ // get host name from URL preg_match("/^(http:\/\/)?([^\/]+)/i", "http://www.php.net/index.html", $matches); @@ -137,12 +142,17 @@ // get last two segments of host name preg_match("/[^\.\/]+\.[^\.\/]+$/",$host,$matches); echo "domain name is: ".$matches[0]."\n"; +]]> </programlisting> - </example> + <para> This example will produce: - <programlisting> + <screen> +<![CDATA[ domain name is: php.net - </programlisting> +]]> + </screen> +</para> + </example> See also <function>preg_match_all</function>, <function>preg_replace</function>, and <function>preg_split</function>. @@ -190,22 +200,26 @@ the first parenthesized subpattern, and so on. <informalexample> <programlisting role="php"> -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +<![CDATA[ +preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", + "<b>example: </b><div align=left>this is a test</div>", $out, PREG_PATTERN_ORDER); print $out[0][0].", ".$out[0][1]."\n"; print $out[1][0].", ".$out[1][1]."\n" - </programlisting> - </informalexample> - This example will produce: - <informalexample> - <programlisting> -<b>example: </b>, <div align=left>this is a test</div> +]]> + </programlisting> + <para> + This example will produce: + <screen> +<![CDATA[ +<b>example: </b>, <div align=left>this is a test</div> example: , this is a test - </programlisting> - </informalexample> - So, $out[0] contains array of strings that matched full pattern, - and $out[1] contains array of strings enclosed by tags. +]]> + </screen> + So, $out[0] contains array of strings that matched full pattern, + and $out[1] contains array of strings enclosed by tags. + </para> + </informalexample> </para> </listitem> </varlistentry> @@ -218,18 +232,22 @@ and so on. <informalexample> <programlisting role="php"> -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +<![CDATA[ +preg_match_all ("|<;[^>]+>(.*)</[^>]+>|U", + "<b>example: </b><div align=left>this is a test</div>", $out, PREG_SET_ORDER); print $out[0][0].", ".$out[0][1]."\n"; -print $out[1][0].", ".$out[1][1]."\n" +print $out[1][0].", ".$out[1][1]."\n"; +]]> </programlisting> </informalexample> This example will produce: <informalexample> <programlisting role="php"> -<b>example: </b>, example: -<div align=left>this is a test</div>, this is a test +<![CDATA[ +<b>example: </b>, example: +<div align=left>this is a test</div>, this is a test +]]> </programlisting> </informalexample> In this case, $matches[0] is the first set of matches, and @@ -252,8 +270,10 @@ <example> <title>Getting all phone numbers out of some text.</title> <programlisting role="php"> +<![CDATA[ preg_match_all ("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x", "Call 555-1212 or 1-800-555-1212", $phones); +]]> </programlisting> </example> </para> @@ -261,33 +281,37 @@ <example> <title>Find matching HTML tags (greedy)</title> <programlisting role="php"> +<![CDATA[ // The \\2 is an example of backreferencing. This tells pcre that // it must match the second set of parentheses in the regular expression // itself, which would be the ([\w]+) in this case. The extra backslash is // required because the string is in double quotes. -$html = "<b>bold text</b><a href=howdy.html>click me</a> +$html = "<b>bold text</b><a href=howdy.html>click me</a> -preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches); +preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches); -for ($i=0; $i< count($matches[0]); $i++) { +for ($i=0; $i< count($matches[0]); $i++) { echo "matched: ".$matches[0][$i]."\n"; echo "part 1: ".$matches[1][$i]."\n"; echo "part 2: ".$matches[3][$i]."\n"; echo "part 3: ".$matches[4][$i]."\n\n"; } +]]> </programlisting> </example> This example will produce: <programlisting> -matched: <b>bold text</b> -part 1: <b> +<![CDATA[ +matched: <b>bold text</b> +part 1: <b> part 2: bold text -part 3: </b> +part 3: </b> -matched: <a href=howdy.html>click me</a> -part 1: <a href=howdy.html> +matched: <a href=howdy.html>click me</a> +part 1: <a href=howdy.html> part 2: click me -part 3: </a> +part 3: </a> +]]> </programlisting> </para> <simpara> @@ -378,37 +402,44 @@ <example> <title>Replacing several values</title> <programlisting> +<![CDATA[ $patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/", "/^\s*{(\w+)}\s*=/"); $replace = array ("\\3/\\4/\\1\\2", "$\\1 ="); print preg_replace ($patterns, $replace, "{startDate} = 1999-5-27"); +]]> </programlisting> </example> This example will produce: <programlisting> +<![CDATA[ $startDate = 5/27/1999 +]]> </programlisting> <example> <title>Using /e modifier</title> <programlisting role="php"> -preg_replace ("/(<\/?)(\w+)([^>]*>)/e", +<![CDATA[ +preg_replace ("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); +]]> </programlisting> <para> -This would capitalize all HTML tags in the input text. + This would capitalize all HTML tags in the input text. </para> </example> <example> <title>Convert HTML to text</title> <programlisting role="php"> +<![CDATA[ // $document should contain an HTML document. // This will remove HTML tags, javascript sections // and white space. It will also convert some // common HTML entities to their text equivalent. -$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript - "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags +$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript + "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace html entities "'&(amp|#38);'i", @@ -426,8 +457,8 @@ "\\1", "\"", "&", - "<", - ">", + "<", + ">", " ", chr(161), chr(162), @@ -436,6 +467,7 @@ "chr(\\1)"); $text = preg_replace ($search, $replace, $document); +]]> </programlisting> </example> </para> @@ -552,9 +584,11 @@ <example> <title><function>preg_split</function> example : Get the parts of a search string.</title> <programlisting role="php"> +<![CDATA[ // split the phrase by any number of commas or space characters, // which include " ", \r, \t, \n and \f $keywords = preg_split ("/[\s,]+/", "hypertext language, programming"); +]]> </programlisting> </example> </para> @@ -562,9 +596,11 @@ <example> <title>Splitting a string into component characters.</title> <programlisting role="php"> +<![CDATA[ $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); +]]> </programlisting> </example> </para> @@ -611,21 +647,23 @@ used delimiter.</para> <para> The special regular expression characters are: - <screen>. \\ + * ? [ ^ ] $ ( ) { } = ! < > | :</screen> + <screen>. \\ + * ? [ ^ ] $ ( ) { } = ! < > | :</screen> </para> <para> <example> <title></title> <programlisting role="php"> +<![CDATA[ $keywords = "$40 for a g3/400"; $keywords = preg_quote ($keywords, "/"); echo $keywords; // returns \$40 for a g3\/400 +]]> </programlisting> </example> <example> <title>Italicizing a word within some text</title> <programlisting role="php"> - +<![CDATA[ // In this example, preg_quote($word) is used to keep the // asterisks from having special meaning to the regular // expression. @@ -633,8 +671,9 @@ $textbody = "This book is *very* difficult to find."; $word = "*very*"; $textbody = preg_replace ("/".preg_quote($word)."/", - "<i>".$word."</i>", + "<i>".$word."</i>", $textbody); +]]> </programlisting> </example> </para> @@ -673,9 +712,11 @@ <example> <title><function>preg_grep</function> example</title> <programlisting role="php"> +<![CDATA[ // return all array elements // containing floating point numbers $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/pdf.xml diff -u phpdoc/en/functions/pdf.xml:1.69 phpdoc/en/functions/pdf.xml:1.70 --- phpdoc/en/functions/pdf.xml:1.69 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pdf.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.69 $ --> +<!-- $Revision: 1.70 $ --> <reference id="ref.pdf"> <title>PDF functions </title> <titleabbrev>PDF</titleabbrev> @@ -256,7 +256,8 @@ <example> <title>Creating a PDF document with PDFlib</title> <programlisting> -<?php +<![CDATA[ +<?php $pdf = pdf_new(); pdf_open_file($pdf, "test.pdf"); pdf_set_info($pdf, "Author", "Uwe Steinmann"); @@ -274,21 +275,24 @@ pdf_end_page($pdf); pdf_close($pdf); pdf_delete($pdf); -echo "<A HREF=getpdf.php>finished</A>"; +echo "<A HREF=getpdf.php>finished</A>"; ?> +]]> </programlisting> <simpara> The script <filename>getpdf.php</filename> just returns the pdf document. </simpara> <informalexample> <programlisting> -<?php +<![CDATA[ +<?php $len = filesize($filename); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=foo.pdf"); readfile($filename); ?> +]]> </programlisting> </informalexample> </example> @@ -305,7 +309,8 @@ <example> <title>pdfclock example from PDFlib distribution</title> <programlisting> -<?php +<![CDATA[ +<?php $radius = 200; $margin = 20; $pagecount = 10; @@ -335,7 +340,7 @@ /* minute strokes */ pdf_setlinewidth($pdf, 2.0); - for ($alpha = 0; $alpha < 360; $alpha += 6) { + for ($alpha = 0; $alpha < 360; $alpha += 6) { pdf_rotate($pdf, 6.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin/3, 0.0); @@ -347,7 +352,7 @@ /* 5 minute strokes */ pdf_setlinewidth($pdf, 3.0); - for ($alpha = 0; $alpha < 360; $alpha += 30) { + for ($alpha = 0; $alpha < 360; $alpha += 30) { pdf_rotate($pdf, 30.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin, 0.0); @@ -410,6 +415,7 @@ pdf_delete($pdf); ?> +]]> </programlisting> </example> </para> @@ -1187,14 +1193,16 @@ <example> <title><function>pdf_findfont</function> example</title> <programlisting role="php"> -<php +<![CDATA[ +<?php $font = pdf_findfont($pdf, "Times New Roman", "winansi", 1); if ($font) { pdf_setfont($pdf, $font, 10); } -?> +?> +]]> </programlisting> </example> </para> @@ -1572,7 +1580,8 @@ <example> <title>Creating a PDF document in memory</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pdf = pdf_new(); @@ -1593,6 +1602,7 @@ echo $data; ?> +]]> </programlisting> </example> </para> @@ -1712,7 +1722,8 @@ <example> <title>Including a memory image</title> <programlisting> -<?php +<![CDATA[ +<?php $im = ImageCreate(100, 100); $col = ImageColorAllocate($im, 80, 45, 190); ImageFill($im, 10, 10, $col); @@ -1721,6 +1732,7 @@ pdf_place_image($pdf, $pim, 100, 100, 1); pdf_close_image($pdf, $pim); ?> +]]> </programlisting> </example></para> <para> Index: phpdoc/en/functions/pfpro.xml diff -u phpdoc/en/functions/pfpro.xml:1.9 phpdoc/en/functions/pfpro.xml:1.10 --- phpdoc/en/functions/pfpro.xml:1.9 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pfpro.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <reference id="ref.pfpro"> <title>Verisign Payflow Pro functions</title> <titleabbrev>Verisign Payflow Pro</titleabbrev> @@ -180,7 +180,8 @@ <example> <title>Payflow Pro example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php pfpro_init(); @@ -211,6 +212,7 @@ pfpro_cleanup(); ?> +]]> </programlisting> </example> </refsect1> @@ -277,11 +279,12 @@ <example> <title>Payflow Pro raw example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php pfpro_init(); -$response = pfpro_process("USER=mylogin&PWD[5]=m&ndy&TRXTYPE=S&TENDER=C&AMT=1.50&ACCT=4111111111111111&EXPDATE=0904"); +$response = pfpro_process("USER=mylogin&PWD[5]=m&ndy&TRXTYPE=S&TENDER=C&AMT=1.50&ACCT=4111111111111111&EXPDATE=0904"); if (!$response) { die("Couldn't establish link to Verisign.\n"); @@ -292,6 +295,7 @@ pfpro_cleanup(); ?> +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/pgsql.xml diff -u phpdoc/en/functions/pgsql.xml:1.47 phpdoc/en/functions/pgsql.xml:1.48 --- phpdoc/en/functions/pgsql.xml:1.47 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pgsql.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.47 $ --> +<!-- $Revision: 1.48 $ --> <reference id="ref.pgsql"> <title>PostgreSQL functions</title> <titleabbrev>PostgreSQL</titleabbrev> @@ -89,7 +89,8 @@ <example> <title>Using Large Objects</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $database = pg_Connect ("dbname=jacarta"); pg_exec ($database, "begin"); $oid = pg_locreate ($database); @@ -100,6 +101,7 @@ pg_loclose ($handle); pg_exec ($database, "commit"); ?> +]]> </programlisting> </example> </para> @@ -155,11 +157,13 @@ <example> <title><function>pg_cmdtuples</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $result = pg_exec ($conn, "INSERT INTO publisher VALUES ('Author')"); $cmdtuples = pg_cmdtuples ($result); echo $cmdtuples . " <- cmdtuples affected."; ?> +]]> </programlisting> </example> </para> @@ -211,7 +215,8 @@ <example> <title>Using pg_connect arguments</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $dbconn = pg_Connect ("dbname=mary"); //connect to a database named "mary" $dbconn2 = pg_Connect ("host=localhost port=5432 dbname=mary"); @@ -219,6 +224,7 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaaa"); //connect to a database named "mary" on the host "sheep" with a username and password ?> +]]> </programlisting> </example> The arguments available include <parameter>host</parameter>, @@ -409,7 +415,8 @@ <example> <title>PostgreSQL fetch array</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=publisher"); if (!$conn) { echo "An error occured.\n"; @@ -423,11 +430,12 @@ } $arr = pg_fetch_array ($result, 0); -echo $arr[0] . " <- array\n"; +echo $arr[0] . " <- array\n"; $arr = pg_fetch_array ($result, 1); -echo $arr["author"] . " <- array\n"; +echo $arr["author"] . " <- array\n"; ?> +]]> </programlisting> </example> </refsect1> @@ -483,11 +491,12 @@ <example> <title>Postgres fetch object</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $database = "verlag"; $db_conn = pg_connect ("host=localhost port=5432 dbname=$database"); if (!$db_conn): ?> - <H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php + <H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php exit; endif; @@ -497,11 +506,11 @@ while ($data = pg_fetch_object ($qu, $row)): echo $data->autor." ("; echo $data->jahr ."): "; - echo $data->titel."<BR>"; + echo $data->titel."<BR>"; $row++; endwhile; ?> -<PRE><?php +<PRE><?php $fields[] = Array ("autor", "Author"); $fields[] = Array ("jahr", " Year"); $fields[] = Array ("titel", " Title"); @@ -516,10 +525,11 @@ $row++; endwhile; echo "----------\n"; ?> -</PRE> <?php +</PRE> <?php pg_freeResult ($qu); pg_close ($db_conn); ?> +]]> </programlisting> </example> </para> @@ -557,7 +567,8 @@ <example> <title>Postgres fetch row</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=publisher"); if (!$conn) { echo "An error occured.\n"; @@ -572,18 +583,19 @@ $num = pg_numrows($result); -for ($i=0; $i<$num; $i++) { +for ($i=0; $i < $num; $i++) { $r = pg_fetch_row($result, $i); - for ($j=0; $j<count($r); $j++) { - echo "$r[$j]&nbsp;"; + for ($j=0; $j < count($r); $j++) { + echo "$r[$j] "; } - echo "<BR>"; + echo "<BR>"; } ?> +]]> </programlisting> </example> </para> @@ -1203,7 +1215,8 @@ <example> <title>High-speed insertion of data into a table</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=foo"); pg_exec($conn, "create table bar (a int4, b char(16), d float8)"); pg_exec($conn, "copy bar from stdin"); @@ -1212,6 +1225,7 @@ pg_put_line($conn, "\\.\n"); pg_end_copy($conn); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/printer.xml diff -u phpdoc/en/functions/printer.xml:1.11 phpdoc/en/functions/printer.xml:1.12 --- phpdoc/en/functions/printer.xml:1.11 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/printer.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <reference id="ref.printer"> <title>Printer functions</title> <titleabbrev>Printer</titleabbrev> @@ -41,8 +41,10 @@ <example> <title><function>printer_open</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open("HP Deskjet 930c"); $handle = printer_open(); +]]> </programlisting> </example> </refsect1> @@ -71,9 +73,11 @@ <example> <title><function>printer_abort</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_abort($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -103,8 +107,10 @@ <example> <title><function>printer_close</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -135,9 +141,11 @@ <example> <title><function>printer_write</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_write($handle, "Text to print"); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -219,8 +227,10 @@ <example> <title><function>printer_list</function> example</title> <programlisting role="php"> +<![CDATA[ /* detect locally shared printer */ var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) ); +]]> </programlisting> </example> </refsect1> @@ -448,10 +458,12 @@ <example> <title><function>printer_set_option</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 75); printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -495,9 +507,11 @@ <example> <title><function>printer_get_option</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); print printer_get_option($handle, PRINTER_DRIVERVERSION); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -525,6 +539,7 @@ <example> <title><function>printer_create_dc</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle); printer_start_page($handle); @@ -546,6 +561,7 @@ printer_endpage($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -599,6 +615,7 @@ <example> <title><function>printer_start_doc</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -606,6 +623,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -803,6 +821,7 @@ <function>printer_select_pen</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -817,6 +836,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -951,6 +971,7 @@ <function>printer_select_brush</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -975,6 +996,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1128,6 +1150,7 @@ <function>printer_select_font</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1140,6 +1163,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1170,9 +1194,11 @@ <function>printer_logical_fontheight</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); print printer_logical_fontheight($handle, 72); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1226,6 +1252,7 @@ <title> <function>printer_draw_roundrect</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1244,6 +1271,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1290,6 +1318,7 @@ <function>printer_draw_rectangle</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1308,6 +1337,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1352,6 +1382,7 @@ <function>printer_draw_elipse</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1370,6 +1401,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1401,6 +1433,7 @@ <example> <title><function>printer_draw_text</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1413,6 +1446,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1445,6 +1479,7 @@ <example> <title><function>printer_draw_line</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1460,6 +1495,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1526,6 +1562,7 @@ <example> <title><function>printer_draw_chord</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1544,6 +1581,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1609,6 +1647,7 @@ <example> <title><function>printer_draw_chord</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1627,6 +1666,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1661,6 +1701,7 @@ <example> <title><function>printer_draw_bmp</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1670,6 +1711,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/pspell.xml diff -u phpdoc/en/functions/pspell.xml:1.20 phpdoc/en/functions/pspell.xml:1.21 --- phpdoc/en/functions/pspell.xml:1.20 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pspell.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <!-- pspell currently (2001-08-14) doesn't use resources --> <reference id="ref.pspell"> @@ -46,12 +46,14 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); pspell_add_to_personal ($pspell_link, "Vlad"); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -103,6 +105,7 @@ <example> <title><function>pspell_check</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en"); if (pspell_check ($pspell_link, "testt")) { @@ -110,6 +113,7 @@ } else { echo "Sorry, wrong spelling"; } +]]> </programlisting> </example> </para> @@ -138,6 +142,7 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); @@ -145,6 +150,7 @@ pspell_add_to_personal ($pspell_link, "Vlad"); pspell_clear_session ($pspell_link); pspell_save_wordlist ($pspell_link); //"Vlad" will not be saved +]]> </programlisting> </example> </para> @@ -242,10 +248,12 @@ <example> <title><function>pspell_config_create</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_personal ($pspell_config, "en"); +]]> </programlisting> </example> </para> @@ -276,10 +284,12 @@ <example> <title><function>pspell_config_ignore</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_ignore($pspell_config, 5); $pspell_link = pspell_new_config($pspell_config); pspell_check($pspell_link, "abcd"); //will not result in an error +]]> </programlisting> </example> </para> @@ -333,10 +343,12 @@ <example> <title><function>pspell_config_mode</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_mode($pspell_config, PSPELL_FAST); $pspell_link = pspell_new_config($pspell_config); pspell_check($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -372,10 +384,12 @@ <example> <title><function>pspell_config_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -412,11 +426,13 @@ <example> <title><function>pspell_config_repl</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -451,10 +467,12 @@ <example> <title><function>pspell_config_runtogether</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_runtogether ($pspell_config, true); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -597,8 +615,10 @@ <example> <title><function>pspell_new</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER)); +]]> </programlisting> </example> </para> @@ -636,10 +656,12 @@ <example> <title><function>pspell_new_config</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_config ($pspell_config); +]]> </programlisting> </example> </para> @@ -767,8 +789,10 @@ <example> <title><function>pspell_new_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new_personal ("/var/dictionaries/custom.pws", "en", "", "", "", PSPELL_FAST|PSPELL_RUN_TOGETHER)); +]]> </programlisting> </example> </para> @@ -801,12 +825,14 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/tmp/dicts/newdict"); $pspell_link = pspell_new_config ($pspell_config); pspell_add_to_personal ($pspell_link, "Vlad"); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -845,6 +871,7 @@ <example> <title><function>pspell_store_replacement</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); @@ -852,6 +879,7 @@ pspell_store_replacement ($pspell_link, $misspelled, $correct); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -880,15 +908,17 @@ <example> <title><function>pspell_suggest</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en"); if (!pspell_check ($pspell_link, "testt")) { $suggestions = pspell_suggest ($pspell_link, "testt"); foreach ($suggestions as $suggestion) { - echo "Possible spelling: $suggestion<br>"; + echo "Possible spelling: $suggestion<br>"; } } +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/readline.xml diff -u phpdoc/en/functions/readline.xml:1.13 phpdoc/en/functions/readline.xml:1.14 --- phpdoc/en/functions/readline.xml:1.13 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/readline.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <reference id="ref.readline"> <title>GNU Readline</title> <titleabbrev>Readline</titleabbrev> @@ -47,6 +47,7 @@ <example> <title><function>readline</function></title> <programlisting role="php"> +<![CDATA[ //get 3 commands from user for ($i=0; $i < 3; $i++) { $line = readline ("Command: "); @@ -58,6 +59,7 @@ //dump variables print_r (readline_info()); +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/recode.xml diff -u phpdoc/en/functions/recode.xml:1.15 phpdoc/en/functions/recode.xml:1.16 --- phpdoc/en/functions/recode.xml:1.15 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/recode.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <reference id="ref.recode"> <title>GNU Recode functions</title> <titleabbrev>Recode</titleabbrev> @@ -48,7 +48,9 @@ <example> <title>Basic <function>recode_string</function> example:</title> <programlisting role="php"> -print recode_string ("us..flat", "The following character has a diacritical mark: &aacute;"); +<![CDATA[ +print recode_string ("us..flat", "The following character has a diacritical mark: á"); +]]> </programlisting> </example> </para> @@ -110,9 +112,11 @@ <example> <title>Basic <function>recode_file</function> example</title> <programlisting role="php"> +<![CDATA[ $input = fopen ('input.txt', 'r'); $output = fopen ('output.txt', 'w'); -recode_file ("us..flat", $input, $output); +recode_file ("us..flat", $input, $output); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/regex.xml diff -u phpdoc/en/functions/regex.xml:1.30 phpdoc/en/functions/regex.xml:1.31 --- phpdoc/en/functions/regex.xml:1.30 Sun Nov 11 11:27:56 2001 +++ phpdoc/en/functions/regex.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.30 $ --> +<!-- $Revision: 1.31 $ --> <reference id="ref.regex"> <title>Regular Expression Functions (POSIX Extended)</title> <titleabbrev>Regexps</titleabbrev> @@ -55,16 +55,17 @@ <example> <title>Regular Expression Examples</title> <programlisting role="php"> -ereg ("abc", $string); -/* Returns true if "abc" +<![CDATA[ +ereg ("abc", $string); +/* Returns true if"abc" is found anywhere in $string. */ -ereg ("^abc", $string); -/* Returns true if "abc" +ereg ("^abc", $string); +/* Returns true if "abc"; is found at the beginning of $string. */ ereg ("abc$", $string); -/* Returns true if "abc" +/* Returns true if "abc" is found at the end of $string. */ eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT); @@ -75,15 +76,16 @@ /* Places three space separated words into $regs[1], $regs[2] and $regs[3]. */ -$string = ereg_replace ("^", "<br />", $string); -/* Put a <br /> tag at the beginning of $string. */ +$string = ereg_replace ("^", "<br />", $string); +/* Put a <br /> tag at the beginning of $string. */ -$string = ereg_replace ("$", "<br />", $string); -/* Put a <br /> tag at the end of $string. */ +$string = ereg_replace ("$", "<br />", $string); +/* Put a <br />; tag at the end of $string. */ $string = ereg_replace ("\n", "", $string); /* Get rid of any newline characters in $string. */ +]]> </programlisting> </example> </para> @@ -149,11 +151,13 @@ <example> <title><function>ereg</function> Example</title> <programlisting role="php"> +<![CDATA[ if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) { echo "$regs[3].$regs[2].$regs[1]"; } else { echo "Invalid date format: $date"; } +]]> </programlisting> </example> </para> @@ -219,10 +223,12 @@ <example> <title><function>ereg_replace</function> Example</title> <programlisting> +<![CDATA[ $string = "This is a test"; echo ereg_replace (" is", " was", $string); echo ereg_replace ("( )is", "\\1was", $string); echo ereg_replace ("(( )is)", "\\2was", $string); +]]> </programlisting> </example> </para> @@ -235,7 +241,8 @@ <example> <title><function>ereg_replace</function> Example</title> <programlisting> -<?php +<![CDATA[ +<?php /* This will not work as expected. */ $num = 4; $string = "This string has four words."; @@ -248,6 +255,7 @@ $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has 4 words.' */ ?> +]]> </programlisting> </example> </para> @@ -255,8 +263,10 @@ <example> <title>Replace URLs with links</title> <programlisting role="php"> -$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", - "<a href=\"\\0\">\\0</a>", $text); +<![CDATA[ +$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", + "<a href=\"\\0\">\\0</a>", $text); +]]> </programlisting> </example> </para> @@ -291,9 +301,11 @@ <example> <title><function>eregi</function> example</title> <programlisting role="php"> +<![CDATA[ if (eregi("z", $string)) { echo "'$string' contains a 'z' or 'Z'!"; } +]]> </programlisting> </example> </para> @@ -372,7 +384,9 @@ <example> <title><function>split</function> Example</title> <programlisting role="php"> +<![CDATA[ list($user,$pass,$uid,$gid,$extra)= split (":", $passwd_line, 5); +]]> </programlisting> </example> </para> @@ -392,9 +406,11 @@ <example> <title><function>split</function> Example</title> <programlisting role="php"> +<![CDATA[ $date = "04/30/1973"; // Delimiters may be slash, dot, or hyphen list ($month, $day, $year) = split ('[/.-]', $date); -echo "Month: $month; Day: $day; Year: $year<br>\n"; +echo "Month: $month; Day: $day; Year: $year<br>\n"; +]]> </programlisting> </example> </para> @@ -498,7 +514,9 @@ <example> <title><function>sql_regcase</function> Example</title> <programlisting role="php"> +<![CDATA[ echo sql_regcase ("Foo bar"); +]]> </programlisting> </example> prints <screen>[Ff][Oo][Oo] [Bb][Aa][Rr]</screen>. Index: phpdoc/en/functions/satellite.xml diff -u phpdoc/en/functions/satellite.xml:1.17 phpdoc/en/functions/satellite.xml:1.18 --- phpdoc/en/functions/satellite.xml:1.17 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/satellite.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.17 $ --> +<!-- $Revision: 1.18 $ --> <!-- Author: David Eriksson <david@2good.com> --> <reference id="ref.satellite"> @@ -38,13 +38,15 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ interface MyInterface { void SetInfo (string info); string GetInfo(); attribute int value; } +]]> </programlisting> </example> </para> @@ -52,7 +54,8 @@ <example> <title>PHP code for accessing MyInterface</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $obj->SetInfo ("A 2GooD object"); @@ -63,6 +66,7 @@ echo $obj->value; ?> +]]> </programlisting> </example> </para> @@ -93,10 +97,12 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ enum MyEnum { a,b,c,d,e }; +]]> </programlisting> </example> </para> @@ -104,13 +110,15 @@ <example> <title>PHP code for accessing MyEnum</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $enum = new OrbitEnum ("MyEnum"); echo $enum->a; /* write 0 */ echo $enum->c; /* write 2 */ echo $enum->e; /* write 4 */ ?> +]]> </programlisting> </example> </para> @@ -141,7 +149,8 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ struct MyStruct { short shortvalue; string stringvalue; @@ -151,6 +160,7 @@ void SetValues (MyStruct values); MyStruct GetValues(); } +]]> </programlisting> </example> </para> @@ -158,7 +168,8 @@ <example> <title>PHP code for accessing MyStruct</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $initial_values = new OrbitStruct ("IDL:MyStruct:1.0"); @@ -172,6 +183,7 @@ echo $values->shortvalue; echo $values->stringvalue; ?> +]]> </programlisting> </example> </para> @@ -202,7 +214,8 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ /* ++?????++ Out of Cheese Error. Redo From Start. */ exception OutOfCheeseError { int parameter; @@ -211,6 +224,7 @@ interface AnotherInterface { void AskWhy() raises (OutOfCheeseError); } +]]> </programlisting> </example> </para> @@ -218,7 +232,8 @@ <example> <title>PHP code for handling CORBA exceptions</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $obj->AskWhy(); @@ -230,6 +245,7 @@ } } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/sesam.xml diff -u phpdoc/en/functions/sesam.xml:1.18 phpdoc/en/functions/sesam.xml:1.19 --- phpdoc/en/functions/sesam.xml:1.18 Mon Nov 12 12:54:01 2001 +++ phpdoc/en/functions/sesam.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.sesam"> <title>SESAM database functions</title> <titleabbrev>SESAM</titleabbrev> @@ -63,7 +63,9 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_oml $.SYSLNK.SESAM-SQL.030 +]]> </programlisting> </informalexample> </para> @@ -78,16 +80,20 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_configfile $SESAM.SESAM.CONF.AW +]]> </programlisting> </informalexample> It will usually contain a configuration like (see SESAM reference manual): <informalexample> <programlisting role="bs2000"> +<![CDATA[ CNF=B NAM=K NOTYPE +]]> </programlisting> </informalexample> </para> @@ -104,7 +110,9 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_messagecatalog $.SYSMES.SESAM-SQL.030 +]]> </programlisting> </informalexample> </para> @@ -454,18 +462,22 @@ <example> <title>Creating a "multiple field" column</title> <programlisting role="sesam"> +<![CDATA[ CREATE TABLE multi_field_test ( pkey CHAR(20) PRIMARY KEY, multi(3) CHAR(12) ) +]]> </programlisting> </example> and can be filled in using: <example> <title>Filling a "multiple field" column</title> <programlisting role="sesam"> +<![CDATA[ INSERT INTO multi_field_test (pkey, multi(2..3) ) - VALUES ('Second', <'first_val', 'second_val'>) + VALUES ('Second', <'first_val', 'second_val'>) +]]> </programlisting> </example> Note that (like in this case) leading empty sub-fields are @@ -540,10 +552,12 @@ <example> <title>Connect to a SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (!sesam_connect ("mycatalog", "myschema", "otto") - die("Unable to connect to SESAM"; -?> + die("Unable to connect to SESAM"); +?> +]]> </programlisting> </example> </para> @@ -590,10 +604,12 @@ <example> <title>Closing a SESAM connection</title> <programlisting role="php"> +<![CDATA[ if (sesam_connect ("mycatalog", "myschema", "otto")) { ... some queries and stuff ... sesam_disconnect(); } +]]> </programlisting> </example> </para> @@ -709,10 +725,12 @@ <example> <title>Setting SESAM transaction parameters</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php sesam_settransaction (SESAM_TXISOL_REPEATABLE_READ, SESAM_TXREAD_READONLY); -?> +?> +]]> </programlisting> </example> </para> @@ -756,14 +774,16 @@ <example> <title>Committing an update to the SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (sesam_connect ("mycatalog", "myschema", "otto")) { - if (!sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)")) + if (!sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)")) die("insert failed"); if (!sesam_commit()) die("commit failed"); } -?> +?> +]]> </programlisting> </example> </para> @@ -805,15 +825,17 @@ <example> <title>Discarding an update to the SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (sesam_connect ("mycatalog", "myschema", "otto")) { - if (sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)") - && sesam_execimm ("INSERT INTO othertable VALUES (*, 'Another Test', 1)")) + if (sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)") + && sesam_execimm ("INSERT INTO othertable VALUES (*, 'Another Test', 1)")) sesam_commit(); else sesam_rollback(); } -?> +?> +]]> </programlisting> </example> </para> @@ -863,12 +885,14 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ $stmt = "INSERT INTO mytable VALUES ('one', 'two')"; $result = sesam_execimm ($stmt); $err = sesam_diagnostic(); print ("sqlstate = ".$err["sqlstate"]."\n". "Affected rows = ".$err["rowcount"]." == ". sesam_affected_rows($result)."\n"); +]]> </programlisting> </informalexample> See also: <function>sesam_query</function> and @@ -937,7 +961,8 @@ Show all rows of the "phone" table as a html table </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (!sesam_connect ("phonedb", "demo", "otto")) die ("cannot connect"); $result = sesam_query ("select * from phone"); @@ -945,45 +970,46 @@ $err = sesam_diagnostic(); die ($err["errmsg"]); } -echo "<TABLE BORDER>\n"; +echo "<TABLE BORDER>\n"; // Add title header with column names above the result: if ($cols = sesam_field_array ($result)) { - echo " <TR><TH COLSPAN=".$cols["count"].">Result:</TH></TR>\n"; - echo " <TR>\n"; - for ($col = 0; $col < $cols["count"]; ++$col) { + echo " <TR><TH COLSPAN=".$cols["count"].">Result:</TH></TR>\n"; + echo " <TR>\n"; + for ($col = 0; $col < $cols["count"]; ++$col) { $colattr = $cols[$col]; /* Span the table head over SESAM's "Multiple Fields": */ - if ($colattr["count"] > 1) { - echo " <TH COLSPAN=".$colattr["count"].">".$colattr["name"]. - "(1..".$colattr["count"].")</TH>\n"; + if ($colattr["count"] > 1) { + echo " <TH COLSPAN=".$colattr["count"].">".$colattr["name"]. + "(1..".$colattr["count"].")</TH>\n"; $col += $colattr["count"] - 1; } else - echo " <TH>" . $colattr["name"] . "</TH>\n"; + echo " <TH>" . $colattr["name"] . "</TH>\n"; } - echo " </TR>\n"; + echo " </TR>\n"; } do { // Fetch the result in chunks of 100 rows max. $ok = sesam_fetch_result ($result, 100); - for ($row=0; $row < $ok["rows"]; ++$row) { - echo " <TR>\n"; - for ($col = 0; $col < $ok["cols"]; ++$col) { + for ($row=0; $row < $ok["rows"]; ++$row) { + echo " <TR>\n"; + for ($col = 0; $col < $ok["cols"]; ++$col) { if (isset($ok[$col][$row])) - echo " <TD>" . $ok[$col][$row] . "</TD>\n"; + echo " <TD>" . $ok[$col][$row] . "</TD>\n"; } else { - echo " <TD>-empty-</TD>\n"; + echo " <TD>-empty-</TD>\n"; } } - echo " </TR>\n"; + echo " </TR>\n"; } } while ($ok["truncated"]) { // while there may be more data - echo "</TABLE>\n"; + echo "</TABLE>\n"; } // free result id sesam_free_result($result); -?> +?> +]]> </programlisting> </example> </para> @@ -1139,7 +1165,8 @@ <example> <title>Displaying SESAM error messages with error position</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // Function which prints a formatted error message, // displaying a pointer to the syntax error in the // SQL statement @@ -1152,11 +1179,11 @@ --$colspan; if ($err["rowcount"] == 0) --$colspan; - echo "<TABLE BORDER>\n"; - echo "<TR><TH COLSPAN=".$colspan."><FONT COLOR=red>ERROR:</FONT> ". - htmlspecialchars($err["errmsg"])."</TH></TR>\n"; - if ($err["errcol"] >= 0) { - echo "<TR><TD COLSPAN=".$colspan."><PRE>\n"; + echo "<TABLE BORDER>\n"; + echo "<TR><TH COLSPAN=".$colspan."><FONT COLOR=red>ERROR:</FONT> ". + htmlspecialchars($err["errmsg"])."</TH></TR>\n"; + if ($err["errcol"] >= 0) { + echo "<TR><TD COLSPAN=".$colspan."><PRE>\n"; $errstmt = $exec_str."\n"; for ($lin=0; $errstmt != ""; ++$lin) { if ($lin != $err["errlin"]) { // $lin is less or greater than errlin @@ -1171,27 +1198,27 @@ $i = ""; $line = substr ($errstmt, 0, strlen ($errstmt)-strlen($i)+1); $errstmt = substr($i, 1); - for ($col=0; $col < $err["errcol"]; ++$col) + for ($col=0; $col < $err["errcol"]; ++$col) echo (substr($line, $col, 1) == "\t") ? "\t" : "."; - echo "<FONT COLOR=RED><BLINK>\\</BLINK></FONT>\n"; - print "<FONT COLOR=\"#880000\">".htmlspecialchars($line)."</FONT>"; - for ($col=0; $col < $err["errcol"]; ++$col) + echo "<FONT COLOR=RED><BLINK>\\</BLINK></FONT>\n"; + print "<FONT COLOR=\"#880000\">".htmlspecialchars($line)."</FONT>"; + for ($col=0; $col < $err["errcol"]; ++$col) echo (substr ($line, $col, 1) == "\t") ? "\t" : "."; - echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n"; + echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n"; } } - echo "</PRE></TD></TR>\n"; + echo "</PRE></TD></TR>\n"; } - echo "<TR>\n"; - echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; + echo "<TR>\n"; + echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; if ($err["errlin"] != -1) - echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; + echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; if ($err["errcol"] != -1) - echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; + echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; if ($err["rowcount"] != 0) - echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; - echo "</TR>\n"; - echo "</TABLE>\n"; + echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; + echo "</TR>\n"; + echo "</TABLE>\n"; } if (!sesam_connect ("mycatalog", "phoneno", "otto")) @@ -1202,7 +1229,8 @@ " ORDER BY FIRSTNAME"; if (!($result = sesam_query ($stmt))) PrintReturncode ($stmt); -?> +?> +]]> </programlisting> </example> </para> @@ -1350,12 +1378,14 @@ </para> <informalexample> <programlisting role="php"> +<![CDATA[ $result = sesam_execimm ("DELETE FROM PHONE WHERE LASTNAME = '".strtoupper ($name)."'"); if (!$result) { ... error ... } print sesam_affected_rows ($result). " entries with last name ".$name." deleted.\n" +]]> </programlisting> </informalexample> </refsect1> @@ -1380,8 +1410,10 @@ </para> <informalexample> <programlisting role="php"> +<![CDATA[ if (!sesam_execimm ($stmt)) - printf ("%s<br>\n", sesam_errormsg()); + printf ("%s<br>\n", sesam_errormsg()); +]]> </programlisting> </informalexample> <para> @@ -1729,28 +1761,30 @@ <example> <title>SESAM fetch rows</title> <programlisting role="php"> -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +<![CDATA[ +<?php +$result = sesam_query ("SELECT * FROM phone\n". + " WHERE LASTNAME='".strtoupper($name)."'\n". + " ORDER BY FIRSTNAME", 1); if (!$result) { ... error ... } // print the table in backward order -print "<TABLE BORDER>\n"; +print "<TABLE BORDER>\n"; $row = sesam_fetch_row ($result, SESAM_SEEK_LAST); while (is_array ($row)) { - print " <TR>\n"; - for ($col = 0; $col < $row["count"]; ++$col) { - print " <TD>".htmlspecialchars ($row[$col])."</TD>\n"; + print " <TR>\n"; + for ($col = 0; $col < $row["count"]; ++$col) { + print " <TD>".htmlspecialchars ($row[$col])."</TD>\n"; } - print " </TR>\n"; + print " </TR>\n"; // use implied SESAM_SEEK_PRIOR $row = sesam_fetch_row ($result); } -print "</TABLE>\n"; +print "</TABLE>\n"; sesam_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> @@ -1816,8 +1850,11 @@ call <function>sesam_fetch_row</function> or make an alias for the column. <informalexample> - <programlisting> -SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2</programlisting> + <programlisting role="sesam"> +<![CDATA[ +SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2 +]]> + </programlisting> </informalexample> </para> <para> @@ -1831,7 +1868,9 @@ declared as: <informalexample> <programlisting role="sesam"> +<![CDATA[ CREATE TABLE ... ( ... MULTI(3) INT ) +]]> </programlisting> </informalexample> the associative indices used for the individual "multiple field" @@ -1848,25 +1887,27 @@ <example> <title>SESAM fetch array</title> <programlisting role="php"> -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +<![CDATA[ +<?php +$result = sesam_query ("SELECT * FROM phone\n". + " WHERE LASTNAME='".strtoupper($name)."'\n". + " ORDER BY FIRSTNAME", 1); if (!$result) { ... error ... } // print the table: -print "<TABLE BORDER>\n"; -while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { - print " <TR>\n"; - print " <TD>".htmlspecialchars ($row["firstname"])."</TD>\n"; - print " <TD>".htmlspecialchars ($row["lastname"])."</TD>\n"; - print " <TD>".htmlspecialchars ($row["phoneno"])."</TD>\n"; - print " </TR>\n"; +print "<TABLE BORDER>\n"; +while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { + print " <TR>\n"; + print " <TD>".htmlspecialchars ($row["firstname"])."</TD>\n"; + print " <TD>".htmlspecialchars ($row["lastname"])."</TD>\n"; + print " <TD>".htmlspecialchars ($row["phoneno"])."</TD>\n"; + print " </TR>\n"; } -print "</TABLE>\n"; +print "</TABLE>\n"; sesam_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> Index: phpdoc/en/functions/session.xml diff -u phpdoc/en/functions/session.xml:1.55 phpdoc/en/functions/session.xml:1.56 --- phpdoc/en/functions/session.xml:1.55 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/session.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.55 $ --> +<!-- $Revision: 1.56 $ --> <reference id="ref.session"> <title>Session handling functions</title> <titleabbrev>Sessions</titleabbrev> @@ -69,10 +69,12 @@ enabled </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register("count"); $HTTP_SESSION_VARS["count"]++; -?> +?> +]]> </programlisting> </example> </para> @@ -89,10 +91,12 @@ enabled </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register("count"); $count++; -?> +?> +]]> </programlisting> </example> </para> @@ -142,19 +146,21 @@ <example> <title>Counting the number of hits of a single user</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register ("count"); $count++; -?> +?> Hello visitor, you have seen this page <?php echo $count; ?> times.<p> -<php? -# the <?=SID?> is necessary to preserve the session id +<?php +# the <?=SID?> is necessary to preserve the session id # in the case that the user has disabled cookies -?> +?> -To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +]]> </programlisting> </example> </para> @@ -421,14 +427,16 @@ <example> <title><function>session_name</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php # set the session name to WebsiteID $previous_name = session_name ("WebsiteID"); -echo "The previous session name was $previous_name<p>"; -?> +echo "The previous session name was $previous_name<p>"; +?> +]]> </programlisting> </example> <note> @@ -846,8 +854,8 @@ <function>session_set_save_handler</function> example </title> <programlisting role="php"> -<?php - +<![CDATA[ +<?php function open ($save_path, $session_name) { global $sess_save_path, $sess_session_name; @@ -906,7 +914,8 @@ // proceed to use sessions normally -?> +?> +]]> </programlisting> </example> </para> @@ -964,15 +973,17 @@ <example> <title><function>session_cache_limiter</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php # set the cache limiter to 'private' session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); -echo "The cache limiter is now set to $cache_limiter<p>"; -?> +echo "The cache limiter is now set to $cache_limiter<p>"; +?> +]]> </programlisting> </example> <note> Index: phpdoc/en/functions/shmop.xml diff -u phpdoc/en/functions/shmop.xml:1.9 phpdoc/en/functions/shmop.xml:1.10 --- phpdoc/en/functions/shmop.xml:1.9 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/shmop.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <reference id="ref.shmop"> <title>Shared Memory Functions</title> <titleabbrev>shmop</titleabbrev> @@ -24,7 +24,8 @@ <example> <title>Shared Memory Operations Overview</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // Create 100 byte shared memory block with system id if 0xff3 $shm_id = shmop_open(0xff3, "c", 0644, 100); @@ -55,7 +56,8 @@ } shmop_close($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -114,9 +116,11 @@ <example> <title>Create a new shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_id = shmop_open(0x0fff, "c", 0644, 100); -?> +?> +]]> </programlisting> </example> </para> @@ -153,9 +157,11 @@ <example> <title>Reading shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_data = shmop_read($shm_id, 0, 50); -?> +?> +]]> </programlisting> </example> </para> @@ -194,9 +200,11 @@ <example> <title>Writing to shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_bytes_written = shmop_write($shm_id, $my_string, 0); -?> +?> +]]> </programlisting> </example> </para> @@ -235,9 +243,11 @@ <example> <title>Getting the size of the shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_size = shmop_size($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -273,9 +283,11 @@ <example> <title>Deleting shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php shmop_delete($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -310,9 +322,11 @@ <example> <title>Closing shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php shmop_close($shm_id); -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/snmp.xml diff -u phpdoc/en/functions/snmp.xml:1.16 phpdoc/en/functions/snmp.xml:1.17 --- phpdoc/en/functions/snmp.xml:1.16 Mon Nov 12 12:09:12 2001 +++ phpdoc/en/functions/snmp.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.16 $ --> +<!-- $Revision: 1.17 $ --> <reference id="ref.snmp"> <title>SNMP functions</title> <titleabbrev>SNMP</titleabbrev> @@ -16,8 +16,10 @@ #define line. It should look like this afterwards:</simpara> <para> - <programlisting> + <programlisting role="c"> +<![CDATA[ #define NO_ZEROLENGTH_COMMUNITY 1 +]]> </programlisting> </para> @@ -60,7 +62,9 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); +]]> </programlisting> </informalexample> </para> @@ -139,7 +143,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $a = snmpwalk("127.0.0.1", "public", ""); +]]> </programlisting> </informalexample></para> @@ -150,9 +156,11 @@ <informalexample> <programlisting role="php"> -for ($i=0; $i<count($a); $i++) { +<![CDATA[ +for ($i=0; $i < count($a); $i++) { echo $a[$i]; } +]]> </programlisting> </informalexample></para> @@ -204,7 +212,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $a = snmpwalkoid("127.0.0.1", "public", ""); +]]> </programlisting> </informalexample></para> @@ -215,9 +225,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ for (reset($a); $i = key($a); next($a)) { - echo "$i: $a[$i]<br>\n"; + echo "$i: $a[$i]<br>\n"; } +]]> </programlisting> </informalexample></para> @@ -246,7 +258,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $quickprint = snmp_get_quick_print(); +]]> </programlisting> </informalexample></para> @@ -297,12 +311,14 @@ <informalexample> <programlisting role="php"> +<![CDATA[ snmp_set_quick_print(0); $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1"); -echo "$a<BR>\n"; +echo "$a<BR>\n"; snmp_set_quick_print(1); $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1"); -echo "$a<BR>\n"; +echo "$a<BR>\n"; +]]> </programlisting> </informalexample></para> Index: phpdoc/en/functions/sockets.xml diff -u phpdoc/en/functions/sockets.xml:1.23 phpdoc/en/functions/sockets.xml:1.24 --- phpdoc/en/functions/sockets.xml:1.23 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/sockets.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.sockets"> <title>Socket functions</title> <titleabbrev>Sockets</titleabbrev> @@ -48,7 +48,8 @@ side, and echoed back to you. To disconnect, enter 'quit'. </para> <programlisting role="php"> -<?php +<![CDATA[ +<?php error_reporting (E_ALL); /* Allow the script to hang around waiting for connections. */ @@ -57,27 +58,27 @@ $address = '192.168.1.53'; $port = 10000; -if (($sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { +if (($sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { echo "socket() failed: reason: " . strerror ($sock) . "\n"; } -if (($ret = bind ($sock, $address, $port)) < 0) { +if (($ret = bind ($sock, $address, $port)) < 0) { echo "bind() failed: reason: " . strerror ($ret) . "\n"; } -if (($ret = listen ($sock, 5)) < 0) { +if (($ret = listen ($sock, 5)) < 0) { echo "listen() failed: reason: " . strerror ($ret) . "\n"; } do { - if (($msgsock = accept_connect($sock)) < 0) { + if (($msgsock = accept_connect($sock)) < 0) { echo "accept_connect() failed: reason: " . strerror ($msgsock) . "\n"; break; } do { $buf = ''; $ret = read ($msgsock, $buf, 2048); - if ($ret < 0) { + if ($ret < 0) { echo "read() failed: reason: " . strerror ($ret) . "\n"; break 2; } @@ -98,6 +99,7 @@ close ($sock); ?> +]]> </programlisting> </example> </para> @@ -110,10 +112,11 @@ and exits. </para> <programlisting> -<?php +<![CDATA[ +<?php error_reporting (E_ALL); -echo "<h2>TCP/IP Connection</h2>\n"; +echo "<h2>TCP/IP Connection</h2>\n"; /* Get the port for the WWW service. */ $service_port = getservbyname ('www', 'tcp'); @@ -123,7 +126,7 @@ /* Create a TCP/IP socket. */ $socket = socket (AF_INET, SOCK_STREAM, 0); -if ($socket < 0) { +if ($socket < 0) { echo "socket() failed: reason: " . strerror ($socket) . "\n"; } else { "socket() successful: " . strerror ($socket) . "\n"; @@ -131,7 +134,7 @@ echo "Attempting to connect to '$address' on port '$service_port'..."; $result = connect ($socket, $address, $service_port); -if ($result < 0) { +if ($result < 0) { echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n"; } else { echo "OK.\n"; @@ -153,6 +156,7 @@ close ($socket); echo "OK.\n\n"; ?> +]]> </programlisting> </example> </para> @@ -546,7 +550,8 @@ <example> <title><function>strerror</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (($socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { echo "socket() failed: reason: " . strerror ($socket) . "\n"; } @@ -555,6 +560,7 @@ echo "bind() failed: reason: " . strerror ($ret) . "\n"; } ?> +]]> </programlisting> <para> The expected output from the above example (assuming the script Index: phpdoc/en/functions/strings.xml diff -u phpdoc/en/functions/strings.xml:1.126 phpdoc/en/functions/strings.xml:1.127 --- phpdoc/en/functions/strings.xml:1.126 Wed Nov 21 14:13:24 2001 +++ phpdoc/en/functions/strings.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.126 $ --> +<!-- $Revision: 1.127 $ --> <reference id="ref.strings"> <title>String functions</title> <titleabbrev>Strings</titleabbrev> @@ -54,7 +54,9 @@ <example> <title><function>addcslashes</function> example</title> <programlisting role="php"> +<![CDATA[ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); +]]> </programlisting> </example> </para> @@ -64,9 +66,11 @@ characters that you set as the start and end of the range. <informalexample> <programlisting role="php"> +<![CDATA[ echo addcslashes('foo[]', 'A..z'); // All upper and lower-case letters will be escaped // ... but so will the [\]^_` and space characters. +]]> </programlisting> </informalexample> Also, if the first character in a range has a lower ASCII value @@ -76,11 +80,13 @@ ASCII value for a character. <informalexample> <programlisting role="php"> +<![CDATA[ echo addcslashes("zoo['.']", 'z..A'); /* output: \zoo['\.'] */ +]]> </programlisting> </informalexample> <note> @@ -192,11 +198,13 @@ <example> <title><function>chr</function> example</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -242,9 +250,11 @@ <example> <title><function>chunk_split</function> example</title> <programlisting role="php"> +<![CDATA[ # format $data using RFC 2045 semantics $new_string = chunk_split(base64_encode($data)); +]]> </programlisting> </example> This function is significantly faster than @@ -523,7 +533,8 @@ <example> <title><function>echo</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php echo "Hello World"; echo "This spans @@ -554,6 +565,7 @@ ($some_var) ? print('true'): print('false'); // print is a function echo $some_var ? 'true': 'false'; // changing the statement around ?> +]]> </programlisting> </example> </para> @@ -562,7 +574,9 @@ can immediately follow the opening tag with an equals sign. <informalexample> <programlisting role="php"> -I have <?=$foo?> foo. +<![CDATA[ +I have <?=$foo?> foo. +]]> </programlisting> </informalexample> </para> @@ -617,8 +631,10 @@ <example> <title><function>explode</function> example</title> <programlisting role="php"> +<![CDATA[ $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); +]]> </programlisting> </example> </para> @@ -679,9 +695,11 @@ <example> <title>Translation Table Example</title> <programlisting role="php"> +<![CDATA[ $trans = get_html_translation_table(HTML_ENTITIES); -$str = "Hallo & <Frau> & Krämer"; +$str = "Hallo & <Frau> & Krämer"; $encoded = strtr($str, $trans); +]]> </programlisting> </example> The <literal>$encoded</literal> variable will now contain: "Hallo @@ -694,8 +712,10 @@ the direction of the translation. <informalexample> <programlisting role="php"> +<![CDATA[ $trans = array_flip($trans); $original = strtr($str, $trans); +]]> </programlisting> </informalexample> The content of <literal>$original</literal> would be: "Hallo & @@ -739,9 +759,11 @@ <example> <title>Meta Tags Example</title> <programlisting role="html"> -<meta name="author" content="name"> -<meta name="tags" content="php3 documentation"> -</head> <!-- parsing stops here --> +<![CDATA[ +<meta name="author" content="name"> +<meta name="tags" content="php3 documentation"> +</head> <!-- parsing stops here --> +]]> </programlisting> </example> (pay attention to line endings - PHP uses a native function to @@ -947,7 +969,9 @@ <example> <title><function>htmlspecialchars</function> example</title> <programlisting role="php"> -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +<![CDATA[ +$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +]]> </programlisting> </example> </para> @@ -989,7 +1013,9 @@ <example> <title><function>implode</function> example</title> <programlisting role="php"> +<![CDATA[ $colon_separated = implode(":", $array); +]]> </programlisting> </example> </para> @@ -1334,11 +1360,12 @@ <example> <title><function>localeconv</function> example</title> <programlisting role="php"> +<![CDATA[ setlocale(LC_ALL, "en_US"); $locale_info = localeconv(); -echo "<PRE>\n"; +echo "<PRE>\n"; echo "--------------------------------------------\n"; echo " Monetary information for current locale: \n"; echo "--------------------------------------------\n\n"; @@ -1357,7 +1384,8 @@ 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"; +echo "</PRE>\n"; +]]> </programlisting> </example> <para> @@ -1596,9 +1624,11 @@ <example> <title><function>ord</function> example</title> <programlisting role="php"> +<![CDATA[ if (ord($str) == 10) { echo "The first character of \$str is a line feed.\n"; } +]> </programlisting> </example> </para> @@ -1639,11 +1669,13 @@ <example> <title>Using <function>parse_str</function></title> <programlisting role="php"> -$str = "first=value&second[]=this+works&second[]=another"; +<![CDATA[ +$str = "first=value&second[]=this+works&second[]=another"; parse_str($str); echo $first; /* prints "value" */ echo $second[0]; /* prints "this works" */ echo $second[1]; /* prints "another" */ +]]> </programlisting> </example> </para> @@ -1890,12 +1922,14 @@ <example> <title><function>sscanf</function> Example</title> <programlisting role="php"> +<![CDATA[ // 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> If optional parameters are passed, the function will return the @@ -1904,13 +1938,15 @@ <example> <title><function>sscanf</function> - using optional parameters</title> <programlisting role="php"> +<![CDATA[ // get author info and generate DocBook entry $auth = "24\tLewis Carroll"; $n = sscanf($auth,"%d\t%s %s", &$id, &$first, &$last); -echo "<author id='$id'> - <firstname>$first</firstname> - <surname>$last</surname> -</author>\n"; +echo "<author id='$id'> + <firstname>$first</firstname> + <surname>$last</surname> +</author>\n"; +]]> </programlisting> </example> </para> @@ -2062,12 +2098,14 @@ <example> <title>Soundex Examples</title> <programlisting role="php"> +<![CDATA[ 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> @@ -2201,8 +2239,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "There are %d monkeys in the %s"; printf($format,$num,$location); +]]> </programlisting> </example> This might output, "There are 5 monkeys in the tree". But @@ -2212,8 +2252,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "The %s contains %d monkeys"; printf($format,$num,$location); +]]> </programlisting> </example> We now have a problem. The order of the placeholders in the @@ -2224,8 +2266,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "The %2\$s contains %1\$d monkeys"; printf($format,$num,$location); +]]> </programlisting> </example> An added benefit here is that you can repeat the placeholders without @@ -2233,9 +2277,11 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2251,18 +2297,22 @@ <example> <title><function>sprintf</function>: zero-padded integers</title> <programlisting role="php"> +<![CDATA[ $isodate = sprintf("%04d-%02d-%02d", $year, $month, $day); +]]> </programlisting> </example> <example> <title><function>sprintf</function>: formatting currency</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2333,11 +2383,13 @@ <example> <title><function>strcasecmp</function> example</title> <programlisting role="php"> +<![CDATA[ $var1 = "Hello"; $var2 = "hello"; if (!strcasecmp($var1, $var2)) { echo '$var1 is equal to $var2 in a case-insensitive string comparison'; } +]]> </programlisting> </example> </para> @@ -2511,7 +2563,9 @@ <example> <title><function>strip_tags</function> example</title> <programlisting role="php"> -$string = strip_tags($string, '<a><b><i><u>'); +<![CDATA[ +$string = strip_tags($string, '<a><b><i><u>'); +]]> </programlisting> </example> </para> @@ -2665,6 +2719,7 @@ below: <informalexample> <programlisting> +<![CDATA[ $arr1 = $arr2 = array("img12.png","img10.png","img2.png","img1.png"); echo "Standard string comparison\n"; usort($arr1,"strcmp"); @@ -2672,29 +2727,32 @@ echo "\nNatural order string comparison\n"; usort($arr2,"strnatcmp"); print_r($arr2); +]]> </programlisting> </informalexample> The code above will generate the following output: <informalexample> - <programlisting> + <screen> +<![CDATA[ Standard string comparison Array ( - [0] => img1.png - [1] => img10.png - [2] => img12.png - [3] => img2.png + [0] => img1.png + [1] => img10.png + [2] => img12.png + [3] => img2.png ) Natural order string comparison Array ( - [0] => img1.png - [1] => img2.png - [2] => img10.png - [3] => img12.png + [0] => img1.png + [1] => img2.png + [2] => img10.png + [3] => img12.png ) - </programlisting> +]]> + </screen> </informalexample> For more information see: Martin Pool's <ulink url="&url.strnatcmp;">Natural Order String Comparison</ulink> @@ -2853,10 +2911,12 @@ <example> <title><function>str_pad</function> example</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2899,6 +2959,7 @@ the difference: <informalexample> <programlisting role="php"> +<![CDATA[ // in PHP 4.0b3 and newer: $pos = strpos($mystring, "b"); if ($pos === false) { // note: three equal signs @@ -2907,9 +2968,10 @@ // in versions older than 4.0b3: $pos = strpos($mystring, "b"); -if (is_string($pos) && !$pos) { +if (is_string($pos) && !$pos) { // not found... } +]]> </programlisting> </informalexample> </para> @@ -2968,12 +3030,14 @@ <example> <title><function>strrchr</function> example</title> <programlisting role="php"> +<![CDATA[ // 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> </para> @@ -3006,7 +3070,9 @@ <example> <title><function>str_repeat</function> example</title> <programlisting role="php"> +<![CDATA[ echo str_repeat("-=", 10); +]]> </programlisting> </example> <para> @@ -3038,9 +3104,11 @@ <example> <title>Reversing a string with <function>strrev</function></title> <programlisting role="php"> -<php +<![CDATA[ +<php echo strrev("Hello world!"); // outputs "!dlrow olleH" -?> +?> +]]> </programlisting> </example> </para> @@ -3080,6 +3148,7 @@ the difference: <informalexample> <programlisting role="php"> +<![CDATA[ // in PHP 4.0b3 and newer: $pos = strrpos($mystring, "b"); if ($pos === false) { // note: three equal signs @@ -3088,9 +3157,10 @@ // in versions older than 4.0b3: $pos = strrpos($mystring, "b"); -if (is_string($pos) && !$pos) { +if (is_string($pos) && !$pos) { // not found... } +]]> </programlisting> </informalexample> </para> @@ -3133,7 +3203,9 @@ The line of code: <informalexample> <programlisting role="php"> +<![CDATA[ $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 @@ -3182,9 +3254,11 @@ <example> <title><function>strstr</function> example</title> <programlisting role="php"> +<![CDATA[ $email = 'sterling@designmultimedia.com'; $domain = strstr($email, '@'); print $domain; // prints @designmultimedia.com +]]> </programlisting> </example> </para> @@ -3218,12 +3292,14 @@ <example> <title><function>strtok</function> example</title> <programlisting role="php"> +<![CDATA[ $string = "This is an example string"; $tok = strtok($string," "); while ($tok) { - echo "Word=$tok<br>"; + echo "Word=$tok<br>"; $tok = strtok(" "); } +]]> </programlisting> </example> </para> @@ -3273,9 +3349,11 @@ <example> <title><function>strtolower</function> example</title> <programlisting role="php"> +<![CDATA[ $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> <para> @@ -3311,9 +3389,11 @@ <example> <title><function>strtoupper</function> example</title> <programlisting role="php"> +<![CDATA[ $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> <para> @@ -3377,7 +3457,9 @@ <example> <title><function>str_replace</function> example</title> <programlisting role="php"> -$bodytag = str_replace("%body%", "black", "<body text=%body%>"); +<![CDATA[ +$bodytag = str_replace("%body%", "black", "<body text=%body%>"); +]]> </programlisting> </example> </para> @@ -3425,7 +3507,9 @@ <example> <title><function>strtr</function> example</title> <programlisting role="php"> +<![CDATA[ $addr = strtr($addr, "äåö", "aao"); +]]> </programlisting> </example> </para> @@ -3442,8 +3526,10 @@ Examples: <informalexample> <programlisting role="php"> -$trans = array("hello" => "hi", "hi" => "hello"); +<![CDATA[ +$trans = array("hello" => "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans) . "\n"; +]]> </programlisting> </informalexample> This will show: "hello all, I said hi", @@ -3494,8 +3580,10 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", 1); // returns "bcdef" $rest = substr("abcdef", 1, 3); // returns "bcd" +]]> </programlisting> </informalexample> </para> @@ -3507,9 +3595,11 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", -1); // returns "f" $rest = substr("abcdef", -2); // returns "ef" $rest = substr("abcdef", -3, 1); // returns "d" +]]> </programlisting> </informalexample> </para> @@ -3533,7 +3623,9 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", 1, -1); // returns "bcde" +]]> </programlisting> </informalexample> </para> @@ -3568,7 +3660,9 @@ <example> <title><function>substr_count</function> example</title> <programlisting> +<![CDATA[ print substr_count("This is a test", "is"); // prints out 2 +]]> </programlisting> </example> </para> @@ -3624,24 +3718,26 @@ <example> <title><function>substr_replace</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $var = 'ABCDEFGH:/MNRPQR/'; -echo "Original: $var<hr>\n"; +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> </para> @@ -3788,12 +3884,14 @@ <example> <title><function>ucfirst</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! +]]> </programlisting> </example> </para> @@ -3826,12 +3924,14 @@ <example> <title><function>ucwords</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! +]]> </programlisting> </example> <note> @@ -3965,10 +4065,12 @@ <example> <title><function>wordwrap</function> example</title> <programlisting role="php"> +<![CDATA[ $text = "The quick brown fox jumped over the lazy dog."; $newtext = wordwrap( $text, 20 ); echo "$newtext\n"; +]]> </programlisting> </example> </para> @@ -3977,20 +4079,24 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ The quick brown fox jumped over the lazy dog. - </programlisting> +]]> + </screen> </informalexample> </para> <para> <example> <title><function>wordwrap</function> example</title> <programlisting role="php"> +<![CDATA[ $text = "A very long woooooooooooord."; $newtext = wordwrap( $text, 8, "\n", 1); echo "$newtext\n"; +]]> </programlisting> </example> </para> @@ -3999,12 +4105,14 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ A very long wooooooo ooooord. - </programlisting> +]]> + </screen> </informalexample> </para> <para> Index: phpdoc/en/functions/swf.xml diff -u phpdoc/en/functions/swf.xml:1.24 phpdoc/en/functions/swf.xml:1.25 --- phpdoc/en/functions/swf.xml:1.24 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/swf.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.24 $ --> +<!-- $Revision: 1.25 $ --> <reference id="ref.swf"> <title>Shockwave Flash functions</title> <titleabbrev>SWF</titleabbrev> @@ -25,7 +25,8 @@ <example> <title>SWF example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php swf_openfile ("test.swf", 256, 256, 30, 1, 1, 1); swf_ortho2 (-100, 100, -100, 100); swf_defineline (1, -70, 0, 70, 0, .2); @@ -43,7 +44,7 @@ swf_placeobject (11, 60); swf_popmatrix (); -for ($i = 0; $i < 30; $i++) { +for ($i = 0; $i < 30; $i++) { $p = $i/(30-1); swf_pushmatrix (); swf_scale (1-($p*.9), 1, 1); @@ -58,7 +59,7 @@ swf_showframe (); } -for ($i = 0; $i < 30; $i++) { +for ($i = 0; $i < 30; $i++) { swf_removeobject (50); if (($i%4) == 0) { swf_showframe (); @@ -70,7 +71,8 @@ swf_enddoaction (); swf_closefile (); -?> +?> +]]> </programlisting> </example> </para> @@ -172,7 +174,8 @@ and saving it in a database </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // The $text variable is submitted by the // user @@ -236,7 +239,8 @@ @mysql_free_result ($sth); @mysql_close ($dbh); } -> +?> +]]> </programlisting> </example> </para> @@ -1777,6 +1781,7 @@ <function>swf_addbuttonrecord</function> function example </title> <programlisting role="php"> +<![CDATA[ swf_startButton ($objid, TYPE_MENUBUTTON); swf_addButtonRecord (BSDown|BSOver, $buttonImageId, 340); swf_onCondition (MenuEnter); @@ -1784,6 +1789,7 @@ swf_onCondition (MenuExit); swf_actionGetUrl ("", "_level1"); swf_endButton (); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/uodbc.xml diff -u phpdoc/en/functions/uodbc.xml:1.26 phpdoc/en/functions/uodbc.xml:1.27 --- phpdoc/en/functions/uodbc.xml:1.26 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/uodbc.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.26 $ --> +<!-- $Revision: 1.27 $ --> <reference id="ref.odbc"> <title>Unified ODBC functions</title> <titleabbrev>ODBC</titleabbrev> @@ -512,15 +512,19 @@ <example> <title><function>odbc_fetch_into</function> pre 4.0.6 example </title> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $my_array); +]]> </programlisting> <para> or </para> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $row, $my_array); $rc = odbc_fetch_into($res_id, 1, $my_array); +]]> </programlisting> </example> </para> @@ -536,14 +540,18 @@ <example> <title><function>odbc_fetch_into</function> 4.0.6 example</title> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $my_array); +]]> </programlisting> <para> or </para> <programlisting role="php"> +<![CDATA[ $row = 1; $rc = odbc_fetch_into($res_id, $row, $my_array); +]]> </programlisting> </example> </para> @@ -959,8 +967,10 @@ the column number of the field you want; or it can be a string containing the name of the field. For example: <informalexample><programlisting> +<![CDATA[ $item_3 = odbc_result ($Query_ID, 3); $item_val = odbc_result ($Query_ID, "val"); +]]> </programlisting> </informalexample> </para> @@ -1105,6 +1115,7 @@ <example> <title>ODBC Setoption Examples</title> <programlisting role="php"> +<![CDATA[ // 1. Option 102 of SQLSetConnectOption() is SQL_AUTOCOMMIT. // Value 1 of SQL_AUTOCOMMIT is SQL_AUTOCOMMIT_ON. // This example has the same effect as @@ -1118,6 +1129,7 @@ $result = odbc_prepare ($conn, $sql); odbc_setoption ($result, 2, 0, 30); odbc_execute ($result); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/url.xml diff -u phpdoc/en/functions/url.xml:1.19 phpdoc/en/functions/url.xml:1.20 --- phpdoc/en/functions/url.xml:1.19 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/url.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <reference id="ref.url"> <title>URL Functions</title> <titleabbrev>URLs</titleabbrev> @@ -138,16 +138,20 @@ <example> <title><function>rawurlencode</function> example 1</title> <programlisting role="php"> -echo '<a href="ftp://user:', rawurlencode('foo @+%/'), +<![CDATA[ +echo '<a href="ftp://user:', rawurlencode('foo @+%/'), '@ftp.my.com/x.txt">'; +]]> </programlisting> </example> Or, if you pass information in a PATH_INFO component of the URL: <example> <title><function>rawurlencode</function> example 2</title> <programlisting role="php"> -echo '<a href="http://x.com/department_list_script/', +<![CDATA[ +echo '<a href="http://x.com/department_list_script/', rawurlencode('sales and marketing/Miami'), '">'; +]]> </programlisting> </example> </para> @@ -178,14 +182,16 @@ <example> <title><function>urldecode</function> example</title> <programlisting role="php"> -$a = split('&', $QUERY_STRING); +<![CDATA[ +$a = split('&', $QUERY_STRING); $i = 0; -while ($i < count($a)) { +while ($i < count($a)) { $b = split('=', $a[$i]); echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])), ' is ', htmlspecialchars(urldecode($b[1])), "<br>"; $i++; } +]]> </programlisting> </example> </para> @@ -226,7 +232,9 @@ <example> <title><function>urlencode</function> example</title> <programlisting role="php"> -echo '<a href="mycgi?foo=', urlencode($userinput), '">'; +<![CDATA[ +echo '<a href="mycgi?foo=', urlencode($userinput), '">'; +]]> </programlisting> </example> </para> @@ -247,7 +255,9 @@ <example> <title><function>urlencode/htmlentities</function> example</title> <programlisting role="php"> -echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'; +<![CDATA[ +echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'; +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/var.xml diff -u phpdoc/en/functions/var.xml:1.76 phpdoc/en/functions/var.xml:1.77 --- phpdoc/en/functions/var.xml:1.76 Tue Nov 20 20:48:33 2001 +++ phpdoc/en/functions/var.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.76 $ --> +<!-- $Revision: 1.77 $ --> <reference id="ref.variables"> <title>Variable Functions</title> <titleabbrev>Variables</titleabbrev> @@ -56,6 +56,7 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $var = 0; if (empty($var)) { // evaluates true @@ -65,6 +66,7 @@ if (!isset($var)) { // evaluates false echo '$var is not set at all'; } +]]> </programlisting> </informalexample> @@ -103,9 +105,11 @@ <function>floatval</function> on arrays or objects. <informalexample> <programlisting role="php"> +<![CDATA[ $var = '122.34343The'; $float_value_of_var = floatval ($var); print $float_value_of_var; // prints 122.34343 +]]> </programlisting> </informalexample> </para> @@ -226,6 +230,7 @@ variables. <informalexample> <programlisting role="php"> +<![CDATA[ $b = array(1,1,2,3,5,8); $arr = get_defined_vars(); @@ -245,6 +250,7 @@ // print all the available keys for the arrays of variables print_r(array_keys(get_defined_vars())); +]]> </programlisting> </informalexample> </para> @@ -276,6 +282,7 @@ generates an error. <informalexample> <programlisting role="php"> +<![CDATA[ $c = mysql_connect(); echo get_resource_type($c)."\n"; // prints: mysql link @@ -287,6 +294,7 @@ $doc = new_xmldoc("1.0"); echo get_resource_type($doc->doc)."\n"; // prints: domxml document +]]> </programlisting> </informalexample> </para> @@ -338,9 +346,11 @@ </note> <informalexample> <programlisting role="php"> +<![CDATA[ // This will import GET and POST vars // with an "rvar_" prefix import_request_variables("gP", "rvar_"); +]]> </programlisting> </informalexample> <simpara> @@ -715,6 +725,7 @@ For example: <informalexample> <programlisting role="php"> +<![CDATA[ <!-- TODO: better example, this one can be quite misleading for unexperienced programmers --> function show_var($var) { @@ -740,6 +751,7 @@ // [2]=> // string(10) "ferredoxin" // } +]]> </programlisting> </informalexample> </para> @@ -826,6 +838,7 @@ is not equivalent to the PHP &null; constant. <informalexample> <programlisting role="php"> +<![CDATA[ $a = "test"; echo isset ($a); // TRUE @@ -834,6 +847,7 @@ $foo = NULL; print isset ($foo); // FALSE +]]> </programlisting> </informalexample> </para> @@ -880,10 +894,12 @@ <para> <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php $a = array (1, 2, array ("a", "b", "c")); print_r ($a); ?> +]]> </programlisting> </informalexample> </para> @@ -960,6 +976,7 @@ <example> <title><function>serialize</function> example</title> <programlisting role="php"> +<![CDATA[ // $session_data contains a multi-dimensional array with session // information for the current user. We use serialize() to store // it in a database at the end of the request. @@ -971,10 +988,11 @@ if (!odbc_execute ($stmt, &$sqldata)) { $stmt = odbc_prepare($conn, "INSERT INTO sessions (id, data) VALUES(?, ?)"); - if (!odbc_execute($stmt, &$sqldata)) { + if (!odbc_execute($stmt, &$sqldata)) { /* Something went wrong. Bitch, whine and moan. */ } } +]]> </programlisting> </example> </para> @@ -1051,11 +1069,13 @@ <example> <title><function>settype</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = "5bar"; // string $bar = true; // boolean settype($foo, "integer"); // $foo is now 5 (integer) settype($bar, "string"); // $bar is now "1" (string) +]]> </programlisting> </example> </para> @@ -1136,6 +1156,7 @@ <example> <title><function>unserialize</function> example</title> <programlisting role="php"> +<![CDATA[ // Here, we use unserialize() to load session data from a database // into $session_data. This example complements the one described // with <function>serialize</function>. @@ -1154,6 +1175,7 @@ $session_data = array(); } } +]]> </programlisting> </example> </para> @@ -1191,6 +1213,7 @@ <example> <title><function>unset</function> example</title> <programlisting role="php"> +<![CDATA[ // destroy a single variable unset ($foo); @@ -1199,6 +1222,7 @@ // destroy more than one variable unset ($foo1, $foo2, $foo3); +]]> </programlisting> </example> </para> @@ -1214,6 +1238,7 @@ <function>unset</function> was called. <informalexample> <programlisting role="php"> +<![CDATA[ function destroy_foo() { global $foo; unset($foo); @@ -1222,13 +1247,16 @@ $foo = 'bar'; destroy_foo(); echo $foo; +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ bar - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1239,7 +1267,8 @@ was called. <informalexample> <programlisting role="php"> -function foo(&$bar) { +<![CDATA[ +function foo(&$bar) { unset($bar); $bar = "blah"; } @@ -1249,14 +1278,17 @@ foo($bar); echo "$bar\n"; +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ something something - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1265,6 +1297,7 @@ static variable, rather than the static variable itself. <informalexample> <programlisting role="php"> +<![CDATA[ function foo() { static $a; $a++; @@ -1276,27 +1309,32 @@ foo(); foo(); foo(); +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ 1 2 3 - </programlisting> +]]> + </screen> </informalexample> </para> <para> If you would like to <function>unset</function> a global variable inside of a function, you can use the <parameter>$GLOBALS</parameter> array to do so: <informalexample> <programlisting role="php"> +<![CDATA[ function foo() { unset($GLOBALS['bar']); } $bar = "something"; foo(); +]]> </programlisting> </informalexample> </para> @@ -1340,8 +1378,9 @@ <para> <informalexample> <programlisting role="php"> -<pre> -<?php +<![CDATA[ +<pre> +<?php $a = array (1, 2, array ("a", "b", "c")); var_dump ($a); @@ -1372,8 +1411,9 @@ bool(true) */ -?> -</pre> +?>; +</pre> +]]> </programlisting> </informalexample> </para> Index: phpdoc/en/functions/wddx.xml diff -u phpdoc/en/functions/wddx.xml:1.13 phpdoc/en/functions/wddx.xml:1.14 --- phpdoc/en/functions/wddx.xml:1.13 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/wddx.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <reference id="ref.wddx"> <title>WDDX Functions</title> <titleabbrev>WDDX</titleabbrev> @@ -24,9 +24,12 @@ <example> <title>Serializing a single value</title> <programlisting role="php"> -<?php +<![CDATA[ +</php> +<?php print wddx_serialize_value("PHP to WDDX packet example", "PHP packet"); -?> +?> +]]> </programlisting> </example> </para> @@ -34,15 +37,18 @@ This example will produce: <informalexample> <programlisting role="php"> -<wddxPacket version='1.0'><header comment='PHP packet'/><data> -<string>PHP to WDDX packet example</string></data></wddxPacket> +<![CDATA[ +<wddxPacket version='1.0'><header comment='PHP packet'/><data> +<string>PHP to WDDX packet example</string></data></wddxPacket> +]]> </programlisting> </informalexample> <example> <title>Using incremental packets</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pi = 3.1415926; $packet_id = wddx_packet_start("PHP"); wddx_add_vars($packet_id, "pi"); @@ -53,19 +59,22 @@ $packet = wddx_packet_end($packet_id); print $packet; -?> +?> +]]> </programlisting> </example> </para> <para> This example will produce: <informalexample> - <programlisting role="php"> -<wddxPacket version='1.0'><header comment='PHP'/><data><struct> -<var name='pi'><number>3.1415926</number></var><var name='cities'> -<array length='3'><string>Austin</string><string>Novato</string> -<string>Seattle</string></array></var></struct></data></wddxPacket> - </programlisting> + <screen> +<![CDATA[ +<wddxPacket version='1.0'><header comment='PHP'/><data><struct> +<var name='pi'><number>3.1415926</number></var><var name='cities'> +<array length='3'><string>Austin</string><string>Novato</string> +<string>Seattle</string></array></var></struct></data></wddxPacket> +]]> + </screen> </informalexample> </para> </partintro> @@ -127,7 +136,7 @@ <example> <title>wddx_serialize_vars example</title> <programlisting> -<?php +<?php $a = 1; $b = 5.5; $c = array("blue", "orange", "violet"); @@ -135,18 +144,20 @@ $clvars = array("c", "d"); print wddx_serialize_vars("a", "b", $clvars); -?> +?> </programlisting> </example> </para> <para> The above example will produce: - <programlisting> -<wddxPacket version='1.0'><header/><data><struct><var name='a'><number>1</number></var> -<var name='b'><number>5.5</number></var><var name='c'><array length='3'> -<string>blue</string><string>orange</string><string>violet</string></array></var> -<var name='d'><string>colors</string></var></struct></data></wddxPacket> - </programlisting> + <screen> +<![CDATA[ +<wddxPacket version='1.0'><header/><data><struct><var name='a'><number>1</number></var> +<var name='b'><number>5.5</number></var><var name='c'><array length='3'> +<string>blue</string><string>orange</string><string>violet</string></array></var> +<var name='d'><string>colors</string></var></struct></data></wddxPacket> +]]> + </screen> </para> </refsect1> </refentry> Index: phpdoc/en/functions/xml.xml diff -u phpdoc/en/functions/xml.xml:1.20 phpdoc/en/functions/xml.xml:1.21 --- phpdoc/en/functions/xml.xml:1.20 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/xml.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <reference id="ref.xml"> <title>XML parser functions</title> <titleabbrev>XML</titleabbrev> @@ -25,9 +25,11 @@ Makefile that comes with expat does not build a library by default, you can use this make rule for that: <programlisting role="makefile"> +<![CDATA[ libexpat.a: $(OBJS) ar -rc $@ $(OBJS) ranlib $@ +]]> </programlisting> A source RPM package of expat can be found at <ulink url="&url.expat.rpm;">&url.expat.rpm;</ulink>. @@ -273,12 +275,13 @@ <example> <title>Show XML Element Structure</title> <programlisting role="php"> +<![CDATA[ $file = "data.xml"; $depth = array(); function startElement($parser, $name, $attrs) { global $depth; - for ($i = 0; $i < $depth[$parser]; $i++) { + for ($i = 0; $i < $depth[$parser]; $i++) { print " "; } print "$name\n"; @@ -304,6 +307,7 @@ } } xml_parser_free($xml_parser); +]]> </programlisting> </example> </para> @@ -320,24 +324,25 @@ course, this example will only work with a specific XML document type. <programlisting role="php"> +<![CDATA[ $file = "data.xml"; $map_array = array( - "BOLD" => "B", - "EMPHASIS" => "I", - "LITERAL" => "TT" + "BOLD" => "B", + "EMPHASIS" => "I", + "LITERAL" => "TT" ); function startElement($parser, $name, $attrs) { global $map_array; if ($htmltag = $map_array[$name]) { - print "<$htmltag>"; + print "<$htmltag>"; } } function endElement($parser, $name) { global $map_array; if ($htmltag = $map_array[$name]) { - print "</$htmltag>"; + print "</$htmltag>"; } } @@ -362,6 +367,7 @@ } } xml_parser_free($xml_parser); +]]> </programlisting> </para> </example> @@ -385,34 +391,35 @@ <example> <title>External Entity Example</title> <programlisting role="php"> +<![CDATA[ $file = "xmltest.xml"; function trustedFile($file) { // only trust local files owned by ourselves if (!eregi("^([a-z]+)://", $file) - && fileowner($file) == getmyuid()) { + && fileowner($file) == getmyuid()) { return true; } return false; } function startElement($parser, $name, $attribs) { - print "&lt;<font color=\"#0000cc\">$name</font>"; + print "<<font color=\"#0000cc\">$name</font>"; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { - print " <font color=\"#009900\">$k</font>=\"<font - color=\"#990000\">$v</font>\""; + print " <font color=\"#009900\">$k</font>=\"<font + color=\"#990000\">$v</font>\""; } } - print "&gt;"; + print ">"; } function endElement($parser, $name) { - print "&lt;/<font color=\"#0000cc\">$name</font>&gt;"; + print "</<font color=\"#0000cc\">$name</font>>"; } function characterData($parser, $data) { - print "<b>$data</b>"; + print "<b>$data</b>"; } function PIHandler($parser, $target, $data) { @@ -425,7 +432,7 @@ if (trustedFile($parser_file[$parser])) { eval($data); } else { - printf("Untrusted PHP code: <i>%s</i>", + printf("Untrusted PHP code: <i>%s</i>", htmlspecialchars($data)); } break; @@ -433,11 +440,11 @@ } function defaultHandler($parser, $data) { - if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - printf('<font color="#aa00aa">%s</font>', + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + printf('<font color="#aa00aa">%s</font>', htmlspecialchars($data)); } else { - printf('<font size="-1">%s</font>', + printf('<font size="-1">%s</font>', htmlspecialchars($data)); } } @@ -491,7 +498,7 @@ die("could not open XML input"); } -print "<pre>"; +print "<pre>"; while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d\n", @@ -499,11 +506,12 @@ xml_get_current_line_number($xml_parser))); } } -print "</pre>"; +print "</pre>"; print "parse complete\n"; xml_parser_free($xml_parser); -?> +?> +]]> </programlisting> </example> </para> @@ -511,33 +519,35 @@ <example> <title>xmltest.xml</title> <programlisting role="xml"> -<?xml version='1.0'?> -<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ -<!ENTITY plainEntity "FOO entity"> -<!ENTITY systemEntity SYSTEM "xmltest2.xml"> -]> -<chapter> - <TITLE>Title &plainEntity;</TITLE> - <para> - <informaltable> - <tgroup cols="3"> - <tbody> - <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> - <row><entry>a2</entry><entry>c2</entry></row> - <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> - </tbody> - </tgroup> - </informaltable> - </para> - &systemEntity; - <sect1 id="about"> - <title>About this Document</title> - <para> - <!-- this is a comment --> - <?php print 'Hi! This is PHP version '.phpversion(); ?> - </para> - </sect1> -</chapter> +<![CDATA[ +<?xml version='1.0'?> +<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ +<!ENTITY plainEntity "FOO entity"> +<!ENTITY systemEntity SYSTEM "xmltest2.xml"> +]> +<chapter> + <TITLE>Title &plainEntity;</TITLE> + <para> + <informaltable> + <tgroup cols="3"> + <tbody> + <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> + <row><entry>a2</entry><entry>c2</entry></row> + <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> + </tbody> + </tgroup> + </informaltable> + </para> + &systemEntity; + <sect1 id="about"> + <title>About this Document</title> + <para> + <!-- this is a comment --> + <?php print 'Hi! This is PHP version '.phpversion(); ?> + </para> + </sect1> +</chapter> +]]> </programlisting> </example> </para> @@ -546,15 +556,17 @@ <example> <title>xmltest2.xml</title> <programlisting role="xml"> -<?xml version="1.0"?> -<!DOCTYPE foo [ -<!ENTITY testEnt "test entity"> -]> -<foo> - <element attrib="value"/> - &testEnt; - <?php print "This is some more PHP code being executed."; ?> -</foo> +<![CDATA[ +<?xml version="1.0"?> +<!DOCTYPE foo [ +<!ENTITY testEnt "test entity"> +]> +<foo> + <element attrib="value"/> + &testEnt; + <?php print "This is some more PHP code being executed."; ?> +</foo> +]]> </programlisting> </example> </para> @@ -622,19 +634,20 @@ assumed to be methods of <parameter>object</parameter>. </para> <programlisting role="php"> -<?php +<![CDATA[ +<?php class xml { var $parser; function xml() { - $this->parser = xml_parser_create(); - xml_set_object($this->parser,&$this); - xml_set_element_handler($this->parser,"tag_open","tag_close"); - xml_set_character_data_handler($this->parser,"cdata"); + $this->parser = xml_parser_create(); + xml_set_object($this->parser,&$this); + xml_set_element_handler($this->parser,"tag_open","tag_close"); + xml_set_character_data_handler($this->parser,"cdata"); } function parse($data) { - xml_parse($this->parser,$data); + xml_parse($this->parser,$data); } function tag_open($parser,$tag,$attributes) { @@ -652,8 +665,9 @@ } // end of class xml $xml_parser = new xml(); -$xml_parser->parse("<A ID=\"hallo\">PHP</A>"); -?> +$xml_parser->parse("<A ID=\"hallo\">PHP</A>"); +?> +]]> </programlisting> </refsect1> </refentry> @@ -1653,8 +1667,9 @@ <literal>para</literal> tag, and then we parse this an print out the structures generated: <informalexample> - <programlisting> -$simple = "<para><note>simple note</note></para>"; + <programlisting role="php"> +<![CDATA[ +$simple = "<para><note>simple note</note></para>"; $p = xml_parser_create(); xml_parse_into_struct($p,$simple,$vals,$index); xml_parser_free($p); @@ -1662,23 +1677,25 @@ print_r($index); echo "\nVals array\n"; print_r($vals); +]]> </programlisting> </informalexample> When we run that code, the output will be: <informalexample> - <programlisting> + <screen> +<![CDATA[ Index array Array ( - [PARA] => Array + [PARA] => Array ( - [0] => 0 - [1] => 2 + [0] => 0 + [1] => 2 ) - [NOTE] => Array + [NOTE] => Array ( - [0] => 1 + [0] => 1 ) ) @@ -1686,30 +1703,31 @@ Vals array Array ( - [0] => Array + [0] => Array ( - [tag] => PARA - [type] => open - [level] => 1 + [tag] => PARA + [type] => open + [level] => 1 ) - [1] => Array + [1] => Array ( - [tag] => NOTE - [type] => complete - [level] => 2 - [value] => simple note + [tag] => NOTE + [type] => complete + [level] => 2 + [value] => simple note ) - [2] => Array + [2] => Array ( - [tag] => PARA - [type] => close - [level] => 1 + [tag] => PARA + [type] => close + [level] => 1 ) ) - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1722,25 +1740,27 @@ representing a small database of aminoacids information: <example> <title>moldb.xml - small database of molecular information</title> - <programlisting> -<?xml version="1.0"?> -<moldb> - - <molecule> - <name>Alanine</name> - <symbol>ala</symbol> - <code>A</code> - <type>hydrophobic</type> - </molecule> - - <molecule> - <name>Lysine</name> - <symbol>lys</symbol> - <code>K</code> - <type>charged</type> - </molecule> + <programlisting role="xml"> +<![CDATA[ +<?xml version="1.0"?> +<moldb> + + <molecule> + <name>Alanine</name> + <symbol>ala</symbol> + <code>A</code> + <type>hydrophobic</type> + </molecule> + + <molecule> + <name>Lysine</name> + <symbol>lys</symbol> + <code>K</code> + <type>charged</type> + </molecule> -</moldb> +</moldb> +]]> </programlisting> </example> And some code to parse the document and generate the appropriate @@ -1751,7 +1771,8 @@ molecular objects </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php class AminoAcid { var $name; // aa name @@ -1760,8 +1781,8 @@ var $type; // hydrophobic, charged or neutral function AminoAcid ($aa) { - foreach ($aa as $k=>$v) - $this->$k = $aa[$k]; + foreach ($aa as $k=>$v) + $this->$k = $aa[$k]; } } @@ -1775,12 +1796,12 @@ xml_parser_free($parser); // loop through the structures - foreach ($tags as $key=>$val) { + foreach ($tags as $key=>$val) { if ($key == "molecule") { $molranges = $val; // each contiguous pair of array entries are the // lower and upper range for each molecule definition - for ($i=0; $i < count($molranges); $i+=2) { + for ($i=0; $i < count($molranges); $i+=2) { $offset = $molranges[$i] + 1; $len = $molranges[$i + 1] - $offset; $tdb[] = parseMol(array_slice($values, $offset, $len)); @@ -1793,7 +1814,7 @@ } function parseMol($mvalues) { - for ($i=0; $i < count($mvalues); $i++) + for ($i=0; $i < count($mvalues); $i++) $mol[$mvalues[$i]["tag"]] = $mvalues[$i]["value"]; return new AminoAcid($mol); } @@ -1802,7 +1823,8 @@ echo "** Database of AminoAcid objects:\n"; print_r($db); -?> +?> +]]> </programlisting> </example> After executing <filename>parsemoldb.php</filename>, the variable @@ -1810,28 +1832,30 @@ <classname>AminoAcid</classname> objects, and the output of the script confirms that: <informalexample> - <programlisting> + <screen> +<![CDATA[ ** Database of AminoAcid objects: Array ( - [0] => aminoacid Object + [0] => aminoacid Object ( - [name] => Alanine - [symbol] => ala - [code] => A - [type] => hydrophobic + [name] => Alanine + [symbol] => ala + [code] => A + [type] => hydrophobic ) - [1] => aminoacid Object + [1] => aminoacid Object ( - [name] => Lysine - [symbol] => lys - [code] => K - [type] => charged + [name] => Lysine + [symbol] => lys + [code] => K + [type] => charged ) ) - </programlisting> +]]> + </screen> </informalexample> </para> </refsect1> Index: phpdoc/en/functions/xslt.xml diff -u phpdoc/en/functions/xslt.xml:1.24 phpdoc/en/functions/xslt.xml:1.25 --- phpdoc/en/functions/xslt.xml:1.24 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/xslt.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.24 $ --> +<!-- $Revision: 1.25 $ --> <reference id="ref.xslt"> <title>XSLT functions</title> <titleabbrev>XSLT</titleabbrev> @@ -262,7 +262,8 @@ Transforming output through an XSLT stylesheet, using the DOM-XML functions for xml generation </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $xsl_file = "article.xsl"; xslt_output_begintransform($xsl_file); @@ -279,6 +280,7 @@ echo $doc->dumpmem(); xslt_output_endtransform(); +]]> </programlisting> </example> </para> @@ -339,48 +341,49 @@ <example> <title>Using the <function>xslt_process</function> to transform three strings</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php -$xslData = '<xsl:stylesheet +$xslData = '<xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -<xsl:template match="article"> - <table border="1" cellpadding="2" cellspacing="1"> - <tr> - <td width="20%"> +<xsl:template match="article"> + <table border="1" cellpadding="2" cellspacing="1"> + <tr> + <td width="20%"> &#160; - </td> - <td width="80%"> - <h2><xsl:value-of select="title"/></h2> - <h3><xsl:value-of select="author"/></h3> - <br/> + </td> + <td width="80%"> + <h2><xsl:value-of select="title"/></h2> + <h3><xsl:value-of select="author"/></h3> + <br/> - <xsl:copy-of select="p"/> - </td> - </tr> - </table> -</xsl:template> - -</xsl:stylesheet>'; - -$xmlData = '<?xml version="1.0"?> -<article> - <title>Learning German</title> - <author>Sterling Hughes</author> - <p> + <xsl:copy-of select="p"/> + </td> + </tr> + </table> +</xsl:template> + +</xsl:stylesheet>'; + +$xmlData = '<?xml version="1.0"?> +<article> + <title>Learning German</title> + <author>Sterling Hughes</author> + <p> Essential phrases: - <br/> - K&#246;nnen Sie mir sagen, wo die Toilette ist?<br/> - Ein grosses Bier, bitte!<br/> - Noch eins, bitte.<br/> - </p> -</article>'; + <br/> + K#246;nnen Sie mir sagen, wo die Toilette ist?<br/> + Ein grosses Bier, bitte!<br/> + Noch eins, bitte.<br/> + </p> +</article>'; if (xslt_process($xslData, $xmlData, $result)) { echo "Here is the brilliant in-depth article on learning"; echo " German: "; - echo "<br>\n<br>"; + echo "<br>\n<br>"; echo $result; } else { echo "There was an error that occurred in the XSL transformation...\n"; @@ -389,6 +392,7 @@ exit; } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/yaz.xml diff -u phpdoc/en/functions/yaz.xml:1.21 phpdoc/en/functions/yaz.xml:1.22 --- phpdoc/en/functions/yaz.xml:1.21 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/yaz.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.21 $ --> +<!-- $Revision: 1.22 $ --> <reference id="ref.yaz"> <title>YAZ functions</title> <titleabbrev>YAZ</titleabbrev> @@ -39,7 +39,8 @@ </para> <para> <informalexample> - <programlisting> + <programlisting role="shell"> +<![CDATA[ gunzip -c yaz-1.6.tar.gz|tar xf - gunzip -c php-4.0.X.tar.gz|tar xf - cd yaz-1.6 @@ -50,6 +51,7 @@ ./configure --with-yaz=/usr/bin make make install +]]> </programlisting> </informalexample> </para> @@ -71,33 +73,34 @@ host. </simpara> <programlisting role="php"> +<![CDATA[ $num_hosts = count ($host); if (empty($term) || count($host) == 0) { - echo '<form method="get"> - <input type="checkbox" - name="host[]" value="bagel.indexdata.dk/gils"> + echo '<form method="get"> + <input type="checkbox" + name="host[]" value="bagel.indexdata.dk/gils"> GILS test - <input type="checkbox" - name="host[]" value="localhost:9999/Default"> + <input type="checkbox" + name="host[]" value="localhost:9999/Default"> local test - <input type="checkbox" checked="1" - name="host[]" value="z3950.bell-labs.com/books"> + <input type="checkbox" checked="1" + name="host[]" value="z3950.bell-labs.com/books"> BELL Labs Library - <br> + <br> RPN Query: - <input type="text" size="30" name="term"> - <input type="submit" name="action" value="Search"> + <input type="text" size="30" name="term"> + <input type="submit" name="action" value="Search"> '; } else { - echo 'You searced for ' . htmlspecialchars($term) . '<br>'; - for ($i = 0; $i < $num_hosts; $i++) { + echo 'You searced for ' . htmlspecialchars($term) . '<br>'; + for ($i = 0; $i < $num_hosts; $i++) { $id[] = yaz_connect($host[$i]); yaz_syntax($id[$i],"sutrs"); yaz_search($id[$i],"rpn",$term); } yaz_wait(); - for ($i = 0; $i < $num_hosts; $i++) { - echo '<hr>' . $host[$i] . ":"; + for ($i = 0; $i < $num_hosts; $i++) { + echo '<hr>' . $host[$i] . ":"; $error = yaz_error($id[$i]); if (!empty($error)) { echo "Error: $error"; @@ -105,17 +108,18 @@ $hits = yaz_hits($id[$i]); echo "Result Count $hits"; } - echo '<dl>'; - for ($p = 1; $p <= 10; $p++) { + echo '<dl>'; + for ($p = 1; $p <= 10; $p++) { $rec = yaz_record($id[$i],$p,"string"); if (empty($rec)) continue; - echo "<dt><b>$p</b></dt><dd>"; - echo ereg_replace("\n", "<br>\n",$rec); - echo "</dd>"; + echo "<dt><b>$p</b></dt><dd>"; + echo ereg_replace("\n", "<br>\n",$rec); + echo "</dd>"; } - echo '</dl>'; + echo '</dl>'; } } +]]> </programlisting> </example> </para> @@ -650,29 +654,31 @@ <example> <title>PHP function that scans titles</title> <programlisting> +<![CDATA[ function scan_titles($id, $starterm) { yaz_scan($id,"rpn", "@attr 1=4 " . $starterm); yaz_wait(); $errno = yaz_errno($id); if ($errno == 0) { - $ar = yaz_scan_result($id,&$options); + $ar = yaz_scan_result($id,&$options); echo 'Scan ok; '; - $ar = yaz_scan_result($id, &$options); + $ar = yaz_scan_result($id, &$options); while(list($key,$val)=each($options)) { echo "$key = $val "; } - echo '<br><table><tr><td>'; + echo '<br><table><tr><td>'; while(list($key,list($k, $term, $tcount))=each($ar)) { if (empty($k)) continue; - echo "<tr><td>$term</td><td>"; + echo "<tr><td>$term</td><td>"; echo $tcount; - echo "</td></tr>"; + echo "</td></tr>"; } - echo '</table>'; + echo '</table>'; } else { - echo "Scan failed. Error: " . yaz_error($id) . "<br>"; + echo "Scan failed. Error: " . yaz_error($id) . "<br>"; } } +]]> </programlisting> </example> </para> @@ -748,10 +754,12 @@ target ID. </simpara> <programlisting> +<![CDATA[ $field["ti"] = "1=4"; $field["au"] = "1=1"; $field["isbn"] = "1=7"; yaz_ccl_conf($id,$field); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/zip.xml diff -u phpdoc/en/functions/zip.xml:1.14 phpdoc/en/functions/zip.xml:1.15 --- phpdoc/en/functions/zip.xml:1.14 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/zip.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.14 $ --> +<!-- $Revision: 1.15 $ --> <reference id="ref.zip"> <title>Zip File Functions (Read Only Access)</title> <titleabbrev>Zip</titleabbrev> @@ -41,7 +41,8 @@ <example> <title>Zip Usage Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $zip = zip_open("/tmp/test2.zip"); @@ -68,7 +69,8 @@ } -?> +?> +]]> </programlisting> </example> </sect1> Index: phpdoc/en/functions/zlib.xml diff -u phpdoc/en/functions/zlib.xml:1.19 phpdoc/en/functions/zlib.xml:1.20 --- phpdoc/en/functions/zlib.xml:1.19 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/zlib.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <reference id="ref.zlib"> <title>Zlib Compression Functions</title> <titleabbrev>Zlib</titleabbrev> @@ -40,11 +40,12 @@ </para> <example> <title>Small Zlib Example</title> -<programlisting role="php"> -<?php + <programlisting role="php"> +<![CDATA[ +<?php $filename = tempnam ('/tmp', 'zlibtest').'.gz'; -print "<html>\n<head></head>\n<body>\n<pre>\n"; +print "<html>\n<head></head>\n<body>\n<pre>\n"; $s = "Only a test, test, test, test, test, test, test, test!\n"; // open file for writing with maximum compression @@ -72,9 +73,10 @@ echo "Error with zlib functions!"; } unlink($filename); -print "</pre>\n</h1></body>\n</html>\n"; +print "</pre>\n</h1></body>\n</html>\n"; ?> +]]> </programlisting> </example> </sect1> @@ -314,7 +316,9 @@ <example> <title><function>gzopen</function> Example</title> <programlisting role="php"> +<![CDATA[ $fp = gzopen ("/tmp/file.gz", "r"); +]]> </programlisting> </example> </para> @@ -405,11 +409,13 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ // get contents of a gz-file into a string $filename = "/usr/local/something.txt.gz"; $zd = gzopen ($filename, "r"); $contents = gzread ($zd, 10000); gzclose ($zd); +]]> </programlisting> </informalexample> </para> @@ -787,13 +793,15 @@ <example> <title>Creating a gzip file</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $data = implode("", "bigfile.txt"); $gzdata = gzencode($data, 9); $fp = fopen("bigfile.txt.gz", "w"); fwrite($fp, $gzdata); fclose($fp); -?> +?> +]]> </programlisting> </example> </para>
Index: phpdoc/en/functions/oracle.xml diff -u phpdoc/en/functions/oracle.xml:1.23 phpdoc/en/functions/oracle.xml:1.24 --- phpdoc/en/functions/oracle.xml:1.23 Mon Nov 12 11:39:45 2001 +++ phpdoc/en/functions/oracle.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.oracle"> <title>Oracle functions</title> <titleabbrev>Oracle</titleabbrev> @@ -43,15 +43,17 @@ values if available. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php ora_parse($curs, "declare tmp INTEGER; begin tmp := :in; :out := tmp; :x := 7.77; end;"); ora_bind($curs, "result", ":x", $len, 2); ora_bind($curs, "input", ":in", 5, 1); ora_bind($curs, "output", ":out", 5, 2); $input = 765; ora_exec($curs); -echo "Result: $result<BR>Out: $output<BR>In: $input"; +echo "Result: $result<BR>Out: $output<BR>In: $input"; ?> +]]> </programlisting> </informalexample> </para> @@ -414,12 +416,14 @@ <example> <title>Oracle fetch into array</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php array($results); -ora_fetch_into($cursor, &$results); +ora_fetch_into($cursor, &$results); echo $results[0]; echo $results[1]; ?> +]]> </programlisting> </example> Note that you need to fetch the array by reference. @@ -511,7 +515,7 @@ <informalexample> <programlisting role="php"> $conn = Ora_Logon("user<emphasis>@TNSNAME</emphasis>", "pass"); -</programlisting> + </programlisting> </informalexample> </para> <para> Index: phpdoc/en/functions/outcontrol.xml diff -u phpdoc/en/functions/outcontrol.xml:1.18 phpdoc/en/functions/outcontrol.xml:1.19 --- phpdoc/en/functions/outcontrol.xml:1.18 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/outcontrol.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.outcontrol"> <title>Output Control Functions</title> <titleabbrev>Output Control</titleabbrev> @@ -19,7 +19,8 @@ <example> <title>Output Control example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php ob_start(); echo "Hello\n"; @@ -28,7 +29,8 @@ ob_end_flush(); -?> +?> +]]> </programlisting> </example> </para> @@ -154,7 +156,8 @@ <example> <title>User defined callback function example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function callback($buffer) { @@ -165,30 +168,33 @@ ob_start("callback"); -?> +?> -<html> -<body> -<p>It's like comparing apples to oranges. -</body> -</html> +<html> +<body> +<p>It's like comparing apples to oranges. +</body> +</html> -<?php +<?php ob_end_flush(); -?> +?> +]]> </programlisting> </example> <para> Would produce: <informalexample> <programlisting role="php"> -<html> -<body> -<p>It's like comparing oranges to oranges. -</body> -</html> +<![CDATA[ +<html> +<body> +<p>It's like comparing oranges to oranges. +</body> +</html> +]]> </programlisting> </informalexample> </para> @@ -284,16 +290,18 @@ <example> <title><function>ob_gzhandler</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php ob_start("ob_gzhandler"); ?> -<html> -<body> -<p>This should be a compressed page. -</html> -</body> +<html> +<body> +<p>This should be a compressed page. +</html> +<body> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/ovrimos.xml diff -u phpdoc/en/functions/ovrimos.xml:1.12 phpdoc/en/functions/ovrimos.xml:1.13 --- phpdoc/en/functions/ovrimos.xml:1.12 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/ovrimos.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <reference id="ref.ovrimos"> <title>Ovrimos SQL functions</title> <titleabbrev>OvrimosSQL</titleabbrev> @@ -22,7 +22,8 @@ Connect to Ovrimos SQL Server and select from a system table </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password"); if ($conn != 0) { echo ("Connection ok!"); @@ -34,7 +35,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will just connect to SQL Server. @@ -72,7 +74,8 @@ <example> <title><function>ovrimos_connect</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("server.domain.com", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -84,7 +87,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> The above example will connect to the database and print out the @@ -172,7 +176,8 @@ <example> <title>Connect to Ovrimos SQL Server and prepare a statement</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn=ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn!=0) { echo "Connection ok!"; @@ -192,7 +197,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will connect to Ovrimos SQL Server, prepare a statement and @@ -326,17 +332,18 @@ <example> <title>A fetch into example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn=ovrimos_connect ("neptune", "8001", "admin", "password"); if ($conn!=0) { echo "Connection ok!"; $res=ovrimos_exec ($conn,"select table_id, table_name from sys.tables"); if ($res != 0) { echo "Statement ok!"; - if (ovrimos_fetch_into ($res, &$row)) { + if (ovrimos_fetch_into ($res, &$row)) { list ($table_id, $table_name) = $row; echo "table_id=".$table_id.", table_name=".$table_name."\n"; - if (ovrimos_fetch_into ($res, &$row)) { + if (ovrimos_fetch_into ($res, &$row)) { list ($table_id, $table_name) = $row; echo "table_id=".$table_id.", table_name=".$table_name."\n"; } else { @@ -349,7 +356,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This example will fetch a row. @@ -389,7 +397,8 @@ <example> <title>A fetch row example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("remote.host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -414,7 +423,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will fetch a row and print the result. @@ -478,7 +488,8 @@ <example> <title>Prepare a statement, execute, and view the result</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -498,7 +509,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> This will execute an SQL statement and print the result in an @@ -508,7 +520,8 @@ <example> <title>Ovrimos_result_all with meta-information</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -518,7 +531,7 @@ echo "Statement ok! cursor=".ovrimos_cursor ($res)."\n"; $colnb = ovrimos_num_fields ($res); echo "Output columns=".$colnb."\n"; - for ($i=1; $i<=$colnb; $i++) { + for ($i=1; $i <= $colnb; $i++) { $name = ovrimos_field_name ($res, $i); $type = ovrimos_field_type ($res, $i); $len = ovrimos_field_len ($res, $i); @@ -529,7 +542,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> </para> @@ -537,7 +551,8 @@ <example> <title>ovrimos_result_all example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = ovrimos_connect ("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; @@ -549,7 +564,8 @@ } ovrimos_close($conn); } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/pcntl.xml diff -u phpdoc/en/functions/pcntl.xml:1.6 phpdoc/en/functions/pcntl.xml:1.7 --- phpdoc/en/functions/pcntl.xml:1.6 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/pcntl.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <reference id="ref.pcntl"> <title>Process Control Functions</title> <titleabbrev>PCNTL</titleabbrev> @@ -114,7 +114,8 @@ <example> <title>Process Control Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pid = pcntl_fork(); if ($pid == -1) { @@ -160,6 +161,7 @@ ?> +]]> </programlisting> </example> </sect1> @@ -195,7 +197,8 @@ <example> <title><function>pcntl_fork</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pid = pcntl_fork(); if ($pid == -1) { @@ -206,7 +209,8 @@ // we are the child } -?> +?> +]]> </programlisting> </example> <para> @@ -246,7 +250,8 @@ <example> <title><function>pcntl_signal</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // signal handler function function sig_handler($signo) { @@ -283,7 +288,8 @@ print "Done\n" -?> +?> +]]> </programlisting> </example> <para> Index: phpdoc/en/functions/pcre.xml diff -u phpdoc/en/functions/pcre.xml:1.62 phpdoc/en/functions/pcre.xml:1.63 --- phpdoc/en/functions/pcre.xml:1.62 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/pcre.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.62 $ --> +<!-- $Revision: 1.63 $ --> <reference id="ref.pcre"> <title>Regular Expression Functions (Perl-Compatible)</title> <titleabbrev>PCRE</titleabbrev> @@ -23,7 +23,7 @@ <example> <title>Examples of valid patterns</title> <itemizedlist> - <listitem><simpara>/<\/\w+>/</simpara></listitem> + <listitem><simpara>/<\/\w+>/</simpara></listitem> <listitem><simpara>|(\d{3})-\d+|Sm</simpara></listitem> <listitem><simpara>/^(?i)php[34]/</simpara></listitem> <listitem><simpara>{^\s+(\s+)?$}</simpara></listitem> @@ -102,17 +102,20 @@ <example> <title>Find the string of text "php"</title> <programlisting role="php"> +<![CDATA[ // the "i" after the pattern delimiter indicates a case-insensitive search if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) { print "A match was found."; } else { print "A match was not found."; } +]]> </programlisting> </example> <example> <title>find the word "web"</title> <programlisting role="php"> +<![CDATA[ // the \b in the pattern indicates a word boundary, so only the distinct // word "web" is matched, and not a word partial like "webbing" or "cobweb" if (preg_match ("/\bweb\b/i", "PHP is the web scripting language of choice.")) { @@ -125,11 +128,13 @@ } else { print "A match was not found."; } +]]> </programlisting> </example> <example> <title>Getting the domain name out of a URL</title> <programlisting role="php"> +<![CDATA[ // get host name from URL preg_match("/^(http:\/\/)?([^\/]+)/i", "http://www.php.net/index.html", $matches); @@ -137,12 +142,17 @@ // get last two segments of host name preg_match("/[^\.\/]+\.[^\.\/]+$/",$host,$matches); echo "domain name is: ".$matches[0]."\n"; +]]> </programlisting> - </example> + <para> This example will produce: - <programlisting> + <screen> +<![CDATA[ domain name is: php.net - </programlisting> +]]> + </screen> +</para> + </example> See also <function>preg_match_all</function>, <function>preg_replace</function>, and <function>preg_split</function>. @@ -190,22 +200,26 @@ the first parenthesized subpattern, and so on. <informalexample> <programlisting role="php"> -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +<![CDATA[ +preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", + "<b>example: </b><div align=left>this is a test</div>", $out, PREG_PATTERN_ORDER); print $out[0][0].", ".$out[0][1]."\n"; print $out[1][0].", ".$out[1][1]."\n" - </programlisting> - </informalexample> - This example will produce: - <informalexample> - <programlisting> -<b>example: </b>, <div align=left>this is a test</div> +]]> + </programlisting> + <para> + This example will produce: + <screen> +<![CDATA[ +<b>example: </b>, <div align=left>this is a test</div> example: , this is a test - </programlisting> - </informalexample> - So, $out[0] contains array of strings that matched full pattern, - and $out[1] contains array of strings enclosed by tags. +]]> + </screen> + So, $out[0] contains array of strings that matched full pattern, + and $out[1] contains array of strings enclosed by tags. + </para> + </informalexample> </para> </listitem> </varlistentry> @@ -218,18 +232,22 @@ and so on. <informalexample> <programlisting role="php"> -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +<![CDATA[ +preg_match_all ("|<;[^>]+>(.*)</[^>]+>|U", + "<b>example: </b><div align=left>this is a test</div>", $out, PREG_SET_ORDER); print $out[0][0].", ".$out[0][1]."\n"; -print $out[1][0].", ".$out[1][1]."\n" +print $out[1][0].", ".$out[1][1]."\n"; +]]> </programlisting> </informalexample> This example will produce: <informalexample> <programlisting role="php"> -<b>example: </b>, example: -<div align=left>this is a test</div>, this is a test +<![CDATA[ +<b>example: </b>, example: +<div align=left>this is a test</div>, this is a test +]]> </programlisting> </informalexample> In this case, $matches[0] is the first set of matches, and @@ -252,8 +270,10 @@ <example> <title>Getting all phone numbers out of some text.</title> <programlisting role="php"> +<![CDATA[ preg_match_all ("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x", "Call 555-1212 or 1-800-555-1212", $phones); +]]> </programlisting> </example> </para> @@ -261,33 +281,37 @@ <example> <title>Find matching HTML tags (greedy)</title> <programlisting role="php"> +<![CDATA[ // The \\2 is an example of backreferencing. This tells pcre that // it must match the second set of parentheses in the regular expression // itself, which would be the ([\w]+) in this case. The extra backslash is // required because the string is in double quotes. -$html = "<b>bold text</b><a href=howdy.html>click me</a> +$html = "<b>bold text</b><a href=howdy.html>click me</a> -preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches); +preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches); -for ($i=0; $i< count($matches[0]); $i++) { +for ($i=0; $i< count($matches[0]); $i++) { echo "matched: ".$matches[0][$i]."\n"; echo "part 1: ".$matches[1][$i]."\n"; echo "part 2: ".$matches[3][$i]."\n"; echo "part 3: ".$matches[4][$i]."\n\n"; } +]]> </programlisting> </example> This example will produce: <programlisting> -matched: <b>bold text</b> -part 1: <b> +<![CDATA[ +matched: <b>bold text</b> +part 1: <b> part 2: bold text -part 3: </b> +part 3: </b> -matched: <a href=howdy.html>click me</a> -part 1: <a href=howdy.html> +matched: <a href=howdy.html>click me</a> +part 1: <a href=howdy.html> part 2: click me -part 3: </a> +part 3: </a> +]]> </programlisting> </para> <simpara> @@ -378,37 +402,44 @@ <example> <title>Replacing several values</title> <programlisting> +<![CDATA[ $patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/", "/^\s*{(\w+)}\s*=/"); $replace = array ("\\3/\\4/\\1\\2", "$\\1 ="); print preg_replace ($patterns, $replace, "{startDate} = 1999-5-27"); +]]> </programlisting> </example> This example will produce: <programlisting> +<![CDATA[ $startDate = 5/27/1999 +]]> </programlisting> <example> <title>Using /e modifier</title> <programlisting role="php"> -preg_replace ("/(<\/?)(\w+)([^>]*>)/e", +<![CDATA[ +preg_replace ("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); +]]> </programlisting> <para> -This would capitalize all HTML tags in the input text. + This would capitalize all HTML tags in the input text. </para> </example> <example> <title>Convert HTML to text</title> <programlisting role="php"> +<![CDATA[ // $document should contain an HTML document. // This will remove HTML tags, javascript sections // and white space. It will also convert some // common HTML entities to their text equivalent. -$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript - "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags +$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript + "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace html entities "'&(amp|#38);'i", @@ -426,8 +457,8 @@ "\\1", "\"", "&", - "<", - ">", + "<", + ">", " ", chr(161), chr(162), @@ -436,6 +467,7 @@ "chr(\\1)"); $text = preg_replace ($search, $replace, $document); +]]> </programlisting> </example> </para> @@ -552,9 +584,11 @@ <example> <title><function>preg_split</function> example : Get the parts of a search string.</title> <programlisting role="php"> +<![CDATA[ // split the phrase by any number of commas or space characters, // which include " ", \r, \t, \n and \f $keywords = preg_split ("/[\s,]+/", "hypertext language, programming"); +]]> </programlisting> </example> </para> @@ -562,9 +596,11 @@ <example> <title>Splitting a string into component characters.</title> <programlisting role="php"> +<![CDATA[ $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); +]]> </programlisting> </example> </para> @@ -611,21 +647,23 @@ used delimiter.</para> <para> The special regular expression characters are: - <screen>. \\ + * ? [ ^ ] $ ( ) { } = ! < > | :</screen> + <screen>. \\ + * ? [ ^ ] $ ( ) { } = ! < > | :</screen> </para> <para> <example> <title></title> <programlisting role="php"> +<![CDATA[ $keywords = "$40 for a g3/400"; $keywords = preg_quote ($keywords, "/"); echo $keywords; // returns \$40 for a g3\/400 +]]> </programlisting> </example> <example> <title>Italicizing a word within some text</title> <programlisting role="php"> - +<![CDATA[ // In this example, preg_quote($word) is used to keep the // asterisks from having special meaning to the regular // expression. @@ -633,8 +671,9 @@ $textbody = "This book is *very* difficult to find."; $word = "*very*"; $textbody = preg_replace ("/".preg_quote($word)."/", - "<i>".$word."</i>", + "<i>".$word."</i>", $textbody); +]]> </programlisting> </example> </para> @@ -673,9 +712,11 @@ <example> <title><function>preg_grep</function> example</title> <programlisting role="php"> +<![CDATA[ // return all array elements // containing floating point numbers $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/pdf.xml diff -u phpdoc/en/functions/pdf.xml:1.69 phpdoc/en/functions/pdf.xml:1.70 --- phpdoc/en/functions/pdf.xml:1.69 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pdf.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.69 $ --> +<!-- $Revision: 1.70 $ --> <reference id="ref.pdf"> <title>PDF functions </title> <titleabbrev>PDF</titleabbrev> @@ -256,7 +256,8 @@ <example> <title>Creating a PDF document with PDFlib</title> <programlisting> -<?php +<![CDATA[ +<?php $pdf = pdf_new(); pdf_open_file($pdf, "test.pdf"); pdf_set_info($pdf, "Author", "Uwe Steinmann"); @@ -274,21 +275,24 @@ pdf_end_page($pdf); pdf_close($pdf); pdf_delete($pdf); -echo "<A HREF=getpdf.php>finished</A>"; +echo "<A HREF=getpdf.php>finished</A>"; ?> +]]> </programlisting> <simpara> The script <filename>getpdf.php</filename> just returns the pdf document. </simpara> <informalexample> <programlisting> -<?php +<![CDATA[ +<?php $len = filesize($filename); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=foo.pdf"); readfile($filename); ?> +]]> </programlisting> </informalexample> </example> @@ -305,7 +309,8 @@ <example> <title>pdfclock example from PDFlib distribution</title> <programlisting> -<?php +<![CDATA[ +<?php $radius = 200; $margin = 20; $pagecount = 10; @@ -335,7 +340,7 @@ /* minute strokes */ pdf_setlinewidth($pdf, 2.0); - for ($alpha = 0; $alpha < 360; $alpha += 6) { + for ($alpha = 0; $alpha < 360; $alpha += 6) { pdf_rotate($pdf, 6.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin/3, 0.0); @@ -347,7 +352,7 @@ /* 5 minute strokes */ pdf_setlinewidth($pdf, 3.0); - for ($alpha = 0; $alpha < 360; $alpha += 30) { + for ($alpha = 0; $alpha < 360; $alpha += 30) { pdf_rotate($pdf, 30.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin, 0.0); @@ -410,6 +415,7 @@ pdf_delete($pdf); ?> +]]> </programlisting> </example> </para> @@ -1187,14 +1193,16 @@ <example> <title><function>pdf_findfont</function> example</title> <programlisting role="php"> -<php +<![CDATA[ +<?php $font = pdf_findfont($pdf, "Times New Roman", "winansi", 1); if ($font) { pdf_setfont($pdf, $font, 10); } -?> +?> +]]> </programlisting> </example> </para> @@ -1572,7 +1580,8 @@ <example> <title>Creating a PDF document in memory</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pdf = pdf_new(); @@ -1593,6 +1602,7 @@ echo $data; ?> +]]> </programlisting> </example> </para> @@ -1712,7 +1722,8 @@ <example> <title>Including a memory image</title> <programlisting> -<?php +<![CDATA[ +<?php $im = ImageCreate(100, 100); $col = ImageColorAllocate($im, 80, 45, 190); ImageFill($im, 10, 10, $col); @@ -1721,6 +1732,7 @@ pdf_place_image($pdf, $pim, 100, 100, 1); pdf_close_image($pdf, $pim); ?> +]]> </programlisting> </example></para> <para> Index: phpdoc/en/functions/pfpro.xml diff -u phpdoc/en/functions/pfpro.xml:1.9 phpdoc/en/functions/pfpro.xml:1.10 --- phpdoc/en/functions/pfpro.xml:1.9 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pfpro.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <reference id="ref.pfpro"> <title>Verisign Payflow Pro functions</title> <titleabbrev>Verisign Payflow Pro</titleabbrev> @@ -180,7 +180,8 @@ <example> <title>Payflow Pro example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php pfpro_init(); @@ -211,6 +212,7 @@ pfpro_cleanup(); ?> +]]> </programlisting> </example> </refsect1> @@ -277,11 +279,12 @@ <example> <title>Payflow Pro raw example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php pfpro_init(); -$response = pfpro_process("USER=mylogin&PWD[5]=m&ndy&TRXTYPE=S&TENDER=C&AMT=1.50&ACCT=4111111111111111&EXPDATE=0904"); +$response = pfpro_process("USER=mylogin&PWD[5]=m&ndy&TRXTYPE=S&TENDER=C&AMT=1.50&ACCT=4111111111111111&EXPDATE=0904"); if (!$response) { die("Couldn't establish link to Verisign.\n"); @@ -292,6 +295,7 @@ pfpro_cleanup(); ?> +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/pgsql.xml diff -u phpdoc/en/functions/pgsql.xml:1.47 phpdoc/en/functions/pgsql.xml:1.48 --- phpdoc/en/functions/pgsql.xml:1.47 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pgsql.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.47 $ --> +<!-- $Revision: 1.48 $ --> <reference id="ref.pgsql"> <title>PostgreSQL functions</title> <titleabbrev>PostgreSQL</titleabbrev> @@ -89,7 +89,8 @@ <example> <title>Using Large Objects</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $database = pg_Connect ("dbname=jacarta"); pg_exec ($database, "begin"); $oid = pg_locreate ($database); @@ -100,6 +101,7 @@ pg_loclose ($handle); pg_exec ($database, "commit"); ?> +]]> </programlisting> </example> </para> @@ -155,11 +157,13 @@ <example> <title><function>pg_cmdtuples</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $result = pg_exec ($conn, "INSERT INTO publisher VALUES ('Author')"); $cmdtuples = pg_cmdtuples ($result); echo $cmdtuples . " <- cmdtuples affected."; ?> +]]> </programlisting> </example> </para> @@ -211,7 +215,8 @@ <example> <title>Using pg_connect arguments</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $dbconn = pg_Connect ("dbname=mary"); //connect to a database named "mary" $dbconn2 = pg_Connect ("host=localhost port=5432 dbname=mary"); @@ -219,6 +224,7 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaaa"); //connect to a database named "mary" on the host "sheep" with a username and password ?> +]]> </programlisting> </example> The arguments available include <parameter>host</parameter>, @@ -409,7 +415,8 @@ <example> <title>PostgreSQL fetch array</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=publisher"); if (!$conn) { echo "An error occured.\n"; @@ -423,11 +430,12 @@ } $arr = pg_fetch_array ($result, 0); -echo $arr[0] . " <- array\n"; +echo $arr[0] . " <- array\n"; $arr = pg_fetch_array ($result, 1); -echo $arr["author"] . " <- array\n"; +echo $arr["author"] . " <- array\n"; ?> +]]> </programlisting> </example> </refsect1> @@ -483,11 +491,12 @@ <example> <title>Postgres fetch object</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $database = "verlag"; $db_conn = pg_connect ("host=localhost port=5432 dbname=$database"); if (!$db_conn): ?> - <H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php + <H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php exit; endif; @@ -497,11 +506,11 @@ while ($data = pg_fetch_object ($qu, $row)): echo $data->autor." ("; echo $data->jahr ."): "; - echo $data->titel."<BR>"; + echo $data->titel."<BR>"; $row++; endwhile; ?> -<PRE><?php +<PRE><?php $fields[] = Array ("autor", "Author"); $fields[] = Array ("jahr", " Year"); $fields[] = Array ("titel", " Title"); @@ -516,10 +525,11 @@ $row++; endwhile; echo "----------\n"; ?> -</PRE> <?php +</PRE> <?php pg_freeResult ($qu); pg_close ($db_conn); ?> +]]> </programlisting> </example> </para> @@ -557,7 +567,8 @@ <example> <title>Postgres fetch row</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=publisher"); if (!$conn) { echo "An error occured.\n"; @@ -572,18 +583,19 @@ $num = pg_numrows($result); -for ($i=0; $i<$num; $i++) { +for ($i=0; $i < $num; $i++) { $r = pg_fetch_row($result, $i); - for ($j=0; $j<count($r); $j++) { - echo "$r[$j]&nbsp;"; + for ($j=0; $j < count($r); $j++) { + echo "$r[$j] "; } - echo "<BR>"; + echo "<BR>"; } ?> +]]> </programlisting> </example> </para> @@ -1203,7 +1215,8 @@ <example> <title>High-speed insertion of data into a table</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $conn = pg_pconnect ("dbname=foo"); pg_exec($conn, "create table bar (a int4, b char(16), d float8)"); pg_exec($conn, "copy bar from stdin"); @@ -1212,6 +1225,7 @@ pg_put_line($conn, "\\.\n"); pg_end_copy($conn); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/printer.xml diff -u phpdoc/en/functions/printer.xml:1.11 phpdoc/en/functions/printer.xml:1.12 --- phpdoc/en/functions/printer.xml:1.11 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/printer.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <reference id="ref.printer"> <title>Printer functions</title> <titleabbrev>Printer</titleabbrev> @@ -41,8 +41,10 @@ <example> <title><function>printer_open</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open("HP Deskjet 930c"); $handle = printer_open(); +]]> </programlisting> </example> </refsect1> @@ -71,9 +73,11 @@ <example> <title><function>printer_abort</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_abort($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -103,8 +107,10 @@ <example> <title><function>printer_close</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -135,9 +141,11 @@ <example> <title><function>printer_write</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_write($handle, "Text to print"); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -219,8 +227,10 @@ <example> <title><function>printer_list</function> example</title> <programlisting role="php"> +<![CDATA[ /* detect locally shared printer */ var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) ); +]]> </programlisting> </example> </refsect1> @@ -448,10 +458,12 @@ <example> <title><function>printer_set_option</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 75); printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -495,9 +507,11 @@ <example> <title><function>printer_get_option</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); print printer_get_option($handle, PRINTER_DRIVERVERSION); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -525,6 +539,7 @@ <example> <title><function>printer_create_dc</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle); printer_start_page($handle); @@ -546,6 +561,7 @@ printer_endpage($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -599,6 +615,7 @@ <example> <title><function>printer_start_doc</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -606,6 +623,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -803,6 +821,7 @@ <function>printer_select_pen</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -817,6 +836,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -951,6 +971,7 @@ <function>printer_select_brush</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -975,6 +996,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1128,6 +1150,7 @@ <function>printer_select_font</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1140,6 +1163,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1170,9 +1194,11 @@ <function>printer_logical_fontheight</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); print printer_logical_fontheight($handle, 72); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1226,6 +1252,7 @@ <title> <function>printer_draw_roundrect</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1244,6 +1271,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1290,6 +1318,7 @@ <function>printer_draw_rectangle</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1308,6 +1337,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1352,6 +1382,7 @@ <function>printer_draw_elipse</function> example </title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1370,6 +1401,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1401,6 +1433,7 @@ <example> <title><function>printer_draw_text</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1413,6 +1446,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1445,6 +1479,7 @@ <example> <title><function>printer_draw_line</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1460,6 +1495,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1526,6 +1562,7 @@ <example> <title><function>printer_draw_chord</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1544,6 +1581,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1609,6 +1647,7 @@ <example> <title><function>printer_draw_chord</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1627,6 +1666,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> @@ -1661,6 +1701,7 @@ <example> <title><function>printer_draw_bmp</function> example</title> <programlisting role="php"> +<![CDATA[ $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); @@ -1670,6 +1711,7 @@ printer_end_page($handle); printer_end_doc($handle); printer_close($handle); +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/pspell.xml diff -u phpdoc/en/functions/pspell.xml:1.20 phpdoc/en/functions/pspell.xml:1.21 --- phpdoc/en/functions/pspell.xml:1.20 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/pspell.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <!-- pspell currently (2001-08-14) doesn't use resources --> <reference id="ref.pspell"> @@ -46,12 +46,14 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); pspell_add_to_personal ($pspell_link, "Vlad"); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -103,6 +105,7 @@ <example> <title><function>pspell_check</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en"); if (pspell_check ($pspell_link, "testt")) { @@ -110,6 +113,7 @@ } else { echo "Sorry, wrong spelling"; } +]]> </programlisting> </example> </para> @@ -138,6 +142,7 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); @@ -145,6 +150,7 @@ pspell_add_to_personal ($pspell_link, "Vlad"); pspell_clear_session ($pspell_link); pspell_save_wordlist ($pspell_link); //"Vlad" will not be saved +]]> </programlisting> </example> </para> @@ -242,10 +248,12 @@ <example> <title><function>pspell_config_create</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_personal ($pspell_config, "en"); +]]> </programlisting> </example> </para> @@ -276,10 +284,12 @@ <example> <title><function>pspell_config_ignore</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_ignore($pspell_config, 5); $pspell_link = pspell_new_config($pspell_config); pspell_check($pspell_link, "abcd"); //will not result in an error +]]> </programlisting> </example> </para> @@ -333,10 +343,12 @@ <example> <title><function>pspell_config_mode</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_mode($pspell_config, PSPELL_FAST); $pspell_link = pspell_new_config($pspell_config); pspell_check($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -372,10 +384,12 @@ <example> <title><function>pspell_config_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -412,11 +426,13 @@ <example> <title><function>pspell_config_repl</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -451,10 +467,12 @@ <example> <title><function>pspell_config_runtogether</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_runtogether ($pspell_config, true); $pspell_link = pspell_new_config ($pspell_config); pspell_check ($pspell_link, "thecat"); +]]> </programlisting> </example> </para> @@ -597,8 +615,10 @@ <example> <title><function>pspell_new</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER)); +]]> </programlisting> </example> </para> @@ -636,10 +656,12 @@ <example> <title><function>pspell_new_config</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); $pspell_link = pspell_new_config ($pspell_config); +]]> </programlisting> </example> </para> @@ -767,8 +789,10 @@ <example> <title><function>pspell_new_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new_personal ("/var/dictionaries/custom.pws", "en", "", "", "", PSPELL_FAST|PSPELL_RUN_TOGETHER)); +]]> </programlisting> </example> </para> @@ -801,12 +825,14 @@ <example> <title><function>pspell_add_to_personal</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/tmp/dicts/newdict"); $pspell_link = pspell_new_config ($pspell_config); pspell_add_to_personal ($pspell_link, "Vlad"); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -845,6 +871,7 @@ <example> <title><function>pspell_store_replacement</function></title> <programlisting role="php"> +<![CDATA[ $pspell_config = pspell_config_create ("en"); pspell_config_personal ($pspell_config, "/var/dictionaries/custom.pws"); pspell_config_repl ($pspell_config, "/var/dictionaries/custom.repl"); @@ -852,6 +879,7 @@ pspell_store_replacement ($pspell_link, $misspelled, $correct); pspell_save_wordlist ($pspell_link); +]]> </programlisting> </example> </para> @@ -880,15 +908,17 @@ <example> <title><function>pspell_suggest</function></title> <programlisting role="php"> +<![CDATA[ $pspell_link = pspell_new ("en"); if (!pspell_check ($pspell_link, "testt")) { $suggestions = pspell_suggest ($pspell_link, "testt"); foreach ($suggestions as $suggestion) { - echo "Possible spelling: $suggestion<br>"; + echo "Possible spelling: $suggestion<br>"; } } +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/readline.xml diff -u phpdoc/en/functions/readline.xml:1.13 phpdoc/en/functions/readline.xml:1.14 --- phpdoc/en/functions/readline.xml:1.13 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/readline.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <reference id="ref.readline"> <title>GNU Readline</title> <titleabbrev>Readline</titleabbrev> @@ -47,6 +47,7 @@ <example> <title><function>readline</function></title> <programlisting role="php"> +<![CDATA[ //get 3 commands from user for ($i=0; $i < 3; $i++) { $line = readline ("Command: "); @@ -58,6 +59,7 @@ //dump variables print_r (readline_info()); +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/recode.xml diff -u phpdoc/en/functions/recode.xml:1.15 phpdoc/en/functions/recode.xml:1.16 --- phpdoc/en/functions/recode.xml:1.15 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/recode.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <reference id="ref.recode"> <title>GNU Recode functions</title> <titleabbrev>Recode</titleabbrev> @@ -48,7 +48,9 @@ <example> <title>Basic <function>recode_string</function> example:</title> <programlisting role="php"> -print recode_string ("us..flat", "The following character has a diacritical mark: &aacute;"); +<![CDATA[ +print recode_string ("us..flat", "The following character has a diacritical mark: á"); +]]> </programlisting> </example> </para> @@ -110,9 +112,11 @@ <example> <title>Basic <function>recode_file</function> example</title> <programlisting role="php"> +<![CDATA[ $input = fopen ('input.txt', 'r'); $output = fopen ('output.txt', 'w'); -recode_file ("us..flat", $input, $output); +recode_file ("us..flat", $input, $output); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/regex.xml diff -u phpdoc/en/functions/regex.xml:1.30 phpdoc/en/functions/regex.xml:1.31 --- phpdoc/en/functions/regex.xml:1.30 Sun Nov 11 11:27:56 2001 +++ phpdoc/en/functions/regex.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.30 $ --> +<!-- $Revision: 1.31 $ --> <reference id="ref.regex"> <title>Regular Expression Functions (POSIX Extended)</title> <titleabbrev>Regexps</titleabbrev> @@ -55,16 +55,17 @@ <example> <title>Regular Expression Examples</title> <programlisting role="php"> -ereg ("abc", $string); -/* Returns true if "abc" +<![CDATA[ +ereg ("abc", $string); +/* Returns true if"abc" is found anywhere in $string. */ -ereg ("^abc", $string); -/* Returns true if "abc" +ereg ("^abc", $string); +/* Returns true if "abc"; is found at the beginning of $string. */ ereg ("abc$", $string); -/* Returns true if "abc" +/* Returns true if "abc" is found at the end of $string. */ eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT); @@ -75,15 +76,16 @@ /* Places three space separated words into $regs[1], $regs[2] and $regs[3]. */ -$string = ereg_replace ("^", "<br />", $string); -/* Put a <br /> tag at the beginning of $string. */ +$string = ereg_replace ("^", "<br />", $string); +/* Put a <br /> tag at the beginning of $string. */ -$string = ereg_replace ("$", "<br />", $string); -/* Put a <br /> tag at the end of $string. */ +$string = ereg_replace ("$", "<br />", $string); +/* Put a <br />; tag at the end of $string. */ $string = ereg_replace ("\n", "", $string); /* Get rid of any newline characters in $string. */ +]]> </programlisting> </example> </para> @@ -149,11 +151,13 @@ <example> <title><function>ereg</function> Example</title> <programlisting role="php"> +<![CDATA[ if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) { echo "$regs[3].$regs[2].$regs[1]"; } else { echo "Invalid date format: $date"; } +]]> </programlisting> </example> </para> @@ -219,10 +223,12 @@ <example> <title><function>ereg_replace</function> Example</title> <programlisting> +<![CDATA[ $string = "This is a test"; echo ereg_replace (" is", " was", $string); echo ereg_replace ("( )is", "\\1was", $string); echo ereg_replace ("(( )is)", "\\2was", $string); +]]> </programlisting> </example> </para> @@ -235,7 +241,8 @@ <example> <title><function>ereg_replace</function> Example</title> <programlisting> -<?php +<![CDATA[ +<?php /* This will not work as expected. */ $num = 4; $string = "This string has four words."; @@ -248,6 +255,7 @@ $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has 4 words.' */ ?> +]]> </programlisting> </example> </para> @@ -255,8 +263,10 @@ <example> <title>Replace URLs with links</title> <programlisting role="php"> -$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", - "<a href=\"\\0\">\\0</a>", $text); +<![CDATA[ +$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", + "<a href=\"\\0\">\\0</a>", $text); +]]> </programlisting> </example> </para> @@ -291,9 +301,11 @@ <example> <title><function>eregi</function> example</title> <programlisting role="php"> +<![CDATA[ if (eregi("z", $string)) { echo "'$string' contains a 'z' or 'Z'!"; } +]]> </programlisting> </example> </para> @@ -372,7 +384,9 @@ <example> <title><function>split</function> Example</title> <programlisting role="php"> +<![CDATA[ list($user,$pass,$uid,$gid,$extra)= split (":", $passwd_line, 5); +]]> </programlisting> </example> </para> @@ -392,9 +406,11 @@ <example> <title><function>split</function> Example</title> <programlisting role="php"> +<![CDATA[ $date = "04/30/1973"; // Delimiters may be slash, dot, or hyphen list ($month, $day, $year) = split ('[/.-]', $date); -echo "Month: $month; Day: $day; Year: $year<br>\n"; +echo "Month: $month; Day: $day; Year: $year<br>\n"; +]]> </programlisting> </example> </para> @@ -498,7 +514,9 @@ <example> <title><function>sql_regcase</function> Example</title> <programlisting role="php"> +<![CDATA[ echo sql_regcase ("Foo bar"); +]]> </programlisting> </example> prints <screen>[Ff][Oo][Oo] [Bb][Aa][Rr]</screen>. Index: phpdoc/en/functions/satellite.xml diff -u phpdoc/en/functions/satellite.xml:1.17 phpdoc/en/functions/satellite.xml:1.18 --- phpdoc/en/functions/satellite.xml:1.17 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/satellite.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.17 $ --> +<!-- $Revision: 1.18 $ --> <!-- Author: David Eriksson <david@2good.com> --> <reference id="ref.satellite"> @@ -38,13 +38,15 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ interface MyInterface { void SetInfo (string info); string GetInfo(); attribute int value; } +]]> </programlisting> </example> </para> @@ -52,7 +54,8 @@ <example> <title>PHP code for accessing MyInterface</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $obj->SetInfo ("A 2GooD object"); @@ -63,6 +66,7 @@ echo $obj->value; ?> +]]> </programlisting> </example> </para> @@ -93,10 +97,12 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ enum MyEnum { a,b,c,d,e }; +]]> </programlisting> </example> </para> @@ -104,13 +110,15 @@ <example> <title>PHP code for accessing MyEnum</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $enum = new OrbitEnum ("MyEnum"); echo $enum->a; /* write 0 */ echo $enum->c; /* write 2 */ echo $enum->e; /* write 4 */ ?> +]]> </programlisting> </example> </para> @@ -141,7 +149,8 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ struct MyStruct { short shortvalue; string stringvalue; @@ -151,6 +160,7 @@ void SetValues (MyStruct values); MyStruct GetValues(); } +]]> </programlisting> </example> </para> @@ -158,7 +168,8 @@ <example> <title>PHP code for accessing MyStruct</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $initial_values = new OrbitStruct ("IDL:MyStruct:1.0"); @@ -172,6 +183,7 @@ echo $values->shortvalue; echo $values->stringvalue; ?> +]]> </programlisting> </example> </para> @@ -202,7 +214,8 @@ <para> <example> <title>Sample IDL file</title> - <programlisting> + <programlisting role="idl"> +<![CDATA[ /* ++?????++ Out of Cheese Error. Redo From Start. */ exception OutOfCheeseError { int parameter; @@ -211,6 +224,7 @@ interface AnotherInterface { void AskWhy() raises (OutOfCheeseError); } +]]> </programlisting> </example> </para> @@ -218,7 +232,8 @@ <example> <title>PHP code for handling CORBA exceptions</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $obj = new OrbitObject ($ior); $obj->AskWhy(); @@ -230,6 +245,7 @@ } } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/sesam.xml diff -u phpdoc/en/functions/sesam.xml:1.18 phpdoc/en/functions/sesam.xml:1.19 --- phpdoc/en/functions/sesam.xml:1.18 Mon Nov 12 12:54:01 2001 +++ phpdoc/en/functions/sesam.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.sesam"> <title>SESAM database functions</title> <titleabbrev>SESAM</titleabbrev> @@ -63,7 +63,9 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_oml $.SYSLNK.SESAM-SQL.030 +]]> </programlisting> </informalexample> </para> @@ -78,16 +80,20 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_configfile $SESAM.SESAM.CONF.AW +]]> </programlisting> </informalexample> It will usually contain a configuration like (see SESAM reference manual): <informalexample> <programlisting role="bs2000"> +<![CDATA[ CNF=B NAM=K NOTYPE +]]> </programlisting> </informalexample> </para> @@ -104,7 +110,9 @@ Example: <informalexample> <programlisting role="apache"> +<![CDATA[ php3_sesam_messagecatalog $.SYSMES.SESAM-SQL.030 +]]> </programlisting> </informalexample> </para> @@ -454,18 +462,22 @@ <example> <title>Creating a "multiple field" column</title> <programlisting role="sesam"> +<![CDATA[ CREATE TABLE multi_field_test ( pkey CHAR(20) PRIMARY KEY, multi(3) CHAR(12) ) +]]> </programlisting> </example> and can be filled in using: <example> <title>Filling a "multiple field" column</title> <programlisting role="sesam"> +<![CDATA[ INSERT INTO multi_field_test (pkey, multi(2..3) ) - VALUES ('Second', <'first_val', 'second_val'>) + VALUES ('Second', <'first_val', 'second_val'>) +]]> </programlisting> </example> Note that (like in this case) leading empty sub-fields are @@ -540,10 +552,12 @@ <example> <title>Connect to a SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (!sesam_connect ("mycatalog", "myschema", "otto") - die("Unable to connect to SESAM"; -?> + die("Unable to connect to SESAM"); +?> +]]> </programlisting> </example> </para> @@ -590,10 +604,12 @@ <example> <title>Closing a SESAM connection</title> <programlisting role="php"> +<![CDATA[ if (sesam_connect ("mycatalog", "myschema", "otto")) { ... some queries and stuff ... sesam_disconnect(); } +]]> </programlisting> </example> </para> @@ -709,10 +725,12 @@ <example> <title>Setting SESAM transaction parameters</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php sesam_settransaction (SESAM_TXISOL_REPEATABLE_READ, SESAM_TXREAD_READONLY); -?> +?> +]]> </programlisting> </example> </para> @@ -756,14 +774,16 @@ <example> <title>Committing an update to the SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (sesam_connect ("mycatalog", "myschema", "otto")) { - if (!sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)")) + if (!sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)")) die("insert failed"); if (!sesam_commit()) die("commit failed"); } -?> +?> +]]> </programlisting> </example> </para> @@ -805,15 +825,17 @@ <example> <title>Discarding an update to the SESAM database</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (sesam_connect ("mycatalog", "myschema", "otto")) { - if (sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)") - && sesam_execimm ("INSERT INTO othertable VALUES (*, 'Another Test', 1)")) + if (sesam_execimm ("INSERT INTO mytable VALUES (*, 'Small Test', <0, 8, 15>)") + && sesam_execimm ("INSERT INTO othertable VALUES (*, 'Another Test', 1)")) sesam_commit(); else sesam_rollback(); } -?> +?> +]]> </programlisting> </example> </para> @@ -863,12 +885,14 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ $stmt = "INSERT INTO mytable VALUES ('one', 'two')"; $result = sesam_execimm ($stmt); $err = sesam_diagnostic(); print ("sqlstate = ".$err["sqlstate"]."\n". "Affected rows = ".$err["rowcount"]." == ". sesam_affected_rows($result)."\n"); +]]> </programlisting> </informalexample> See also: <function>sesam_query</function> and @@ -937,7 +961,8 @@ Show all rows of the "phone" table as a html table </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (!sesam_connect ("phonedb", "demo", "otto")) die ("cannot connect"); $result = sesam_query ("select * from phone"); @@ -945,45 +970,46 @@ $err = sesam_diagnostic(); die ($err["errmsg"]); } -echo "<TABLE BORDER>\n"; +echo "<TABLE BORDER>\n"; // Add title header with column names above the result: if ($cols = sesam_field_array ($result)) { - echo " <TR><TH COLSPAN=".$cols["count"].">Result:</TH></TR>\n"; - echo " <TR>\n"; - for ($col = 0; $col < $cols["count"]; ++$col) { + echo " <TR><TH COLSPAN=".$cols["count"].">Result:</TH></TR>\n"; + echo " <TR>\n"; + for ($col = 0; $col < $cols["count"]; ++$col) { $colattr = $cols[$col]; /* Span the table head over SESAM's "Multiple Fields": */ - if ($colattr["count"] > 1) { - echo " <TH COLSPAN=".$colattr["count"].">".$colattr["name"]. - "(1..".$colattr["count"].")</TH>\n"; + if ($colattr["count"] > 1) { + echo " <TH COLSPAN=".$colattr["count"].">".$colattr["name"]. + "(1..".$colattr["count"].")</TH>\n"; $col += $colattr["count"] - 1; } else - echo " <TH>" . $colattr["name"] . "</TH>\n"; + echo " <TH>" . $colattr["name"] . "</TH>\n"; } - echo " </TR>\n"; + echo " </TR>\n"; } do { // Fetch the result in chunks of 100 rows max. $ok = sesam_fetch_result ($result, 100); - for ($row=0; $row < $ok["rows"]; ++$row) { - echo " <TR>\n"; - for ($col = 0; $col < $ok["cols"]; ++$col) { + for ($row=0; $row < $ok["rows"]; ++$row) { + echo " <TR>\n"; + for ($col = 0; $col < $ok["cols"]; ++$col) { if (isset($ok[$col][$row])) - echo " <TD>" . $ok[$col][$row] . "</TD>\n"; + echo " <TD>" . $ok[$col][$row] . "</TD>\n"; } else { - echo " <TD>-empty-</TD>\n"; + echo " <TD>-empty-</TD>\n"; } } - echo " </TR>\n"; + echo " </TR>\n"; } } while ($ok["truncated"]) { // while there may be more data - echo "</TABLE>\n"; + echo "</TABLE>\n"; } // free result id sesam_free_result($result); -?> +?> +]]> </programlisting> </example> </para> @@ -1139,7 +1165,8 @@ <example> <title>Displaying SESAM error messages with error position</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // Function which prints a formatted error message, // displaying a pointer to the syntax error in the // SQL statement @@ -1152,11 +1179,11 @@ --$colspan; if ($err["rowcount"] == 0) --$colspan; - echo "<TABLE BORDER>\n"; - echo "<TR><TH COLSPAN=".$colspan."><FONT COLOR=red>ERROR:</FONT> ". - htmlspecialchars($err["errmsg"])."</TH></TR>\n"; - if ($err["errcol"] >= 0) { - echo "<TR><TD COLSPAN=".$colspan."><PRE>\n"; + echo "<TABLE BORDER>\n"; + echo "<TR><TH COLSPAN=".$colspan."><FONT COLOR=red>ERROR:</FONT> ". + htmlspecialchars($err["errmsg"])."</TH></TR>\n"; + if ($err["errcol"] >= 0) { + echo "<TR><TD COLSPAN=".$colspan."><PRE>\n"; $errstmt = $exec_str."\n"; for ($lin=0; $errstmt != ""; ++$lin) { if ($lin != $err["errlin"]) { // $lin is less or greater than errlin @@ -1171,27 +1198,27 @@ $i = ""; $line = substr ($errstmt, 0, strlen ($errstmt)-strlen($i)+1); $errstmt = substr($i, 1); - for ($col=0; $col < $err["errcol"]; ++$col) + for ($col=0; $col < $err["errcol"]; ++$col) echo (substr($line, $col, 1) == "\t") ? "\t" : "."; - echo "<FONT COLOR=RED><BLINK>\\</BLINK></FONT>\n"; - print "<FONT COLOR=\"#880000\">".htmlspecialchars($line)."</FONT>"; - for ($col=0; $col < $err["errcol"]; ++$col) + echo "<FONT COLOR=RED><BLINK>\\</BLINK></FONT>\n"; + print "<FONT COLOR=\"#880000\">".htmlspecialchars($line)."</FONT>"; + for ($col=0; $col < $err["errcol"]; ++$col) echo (substr ($line, $col, 1) == "\t") ? "\t" : "."; - echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n"; + echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n"; } } - echo "</PRE></TD></TR>\n"; + echo "</PRE></TD></TR>\n"; } - echo "<TR>\n"; - echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; + echo "<TR>\n"; + echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; if ($err["errlin"] != -1) - echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; + echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; if ($err["errcol"] != -1) - echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; + echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; if ($err["rowcount"] != 0) - echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; - echo "</TR>\n"; - echo "</TABLE>\n"; + echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; + echo "</TR>\n"; + echo "</TABLE>\n"; } if (!sesam_connect ("mycatalog", "phoneno", "otto")) @@ -1202,7 +1229,8 @@ " ORDER BY FIRSTNAME"; if (!($result = sesam_query ($stmt))) PrintReturncode ($stmt); -?> +?> +]]> </programlisting> </example> </para> @@ -1350,12 +1378,14 @@ </para> <informalexample> <programlisting role="php"> +<![CDATA[ $result = sesam_execimm ("DELETE FROM PHONE WHERE LASTNAME = '".strtoupper ($name)."'"); if (!$result) { ... error ... } print sesam_affected_rows ($result). " entries with last name ".$name." deleted.\n" +]]> </programlisting> </informalexample> </refsect1> @@ -1380,8 +1410,10 @@ </para> <informalexample> <programlisting role="php"> +<![CDATA[ if (!sesam_execimm ($stmt)) - printf ("%s<br>\n", sesam_errormsg()); + printf ("%s<br>\n", sesam_errormsg()); +]]> </programlisting> </informalexample> <para> @@ -1729,28 +1761,30 @@ <example> <title>SESAM fetch rows</title> <programlisting role="php"> -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +<![CDATA[ +<?php +$result = sesam_query ("SELECT * FROM phone\n". + " WHERE LASTNAME='".strtoupper($name)."'\n". + " ORDER BY FIRSTNAME", 1); if (!$result) { ... error ... } // print the table in backward order -print "<TABLE BORDER>\n"; +print "<TABLE BORDER>\n"; $row = sesam_fetch_row ($result, SESAM_SEEK_LAST); while (is_array ($row)) { - print " <TR>\n"; - for ($col = 0; $col < $row["count"]; ++$col) { - print " <TD>".htmlspecialchars ($row[$col])."</TD>\n"; + print " <TR>\n"; + for ($col = 0; $col < $row["count"]; ++$col) { + print " <TD>".htmlspecialchars ($row[$col])."</TD>\n"; } - print " </TR>\n"; + print " </TR>\n"; // use implied SESAM_SEEK_PRIOR $row = sesam_fetch_row ($result); } -print "</TABLE>\n"; +print "</TABLE>\n"; sesam_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> @@ -1816,8 +1850,11 @@ call <function>sesam_fetch_row</function> or make an alias for the column. <informalexample> - <programlisting> -SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2</programlisting> + <programlisting role="sesam"> +<![CDATA[ +SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2 +]]> + </programlisting> </informalexample> </para> <para> @@ -1831,7 +1868,9 @@ declared as: <informalexample> <programlisting role="sesam"> +<![CDATA[ CREATE TABLE ... ( ... MULTI(3) INT ) +]]> </programlisting> </informalexample> the associative indices used for the individual "multiple field" @@ -1848,25 +1887,27 @@ <example> <title>SESAM fetch array</title> <programlisting role="php"> -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +<![CDATA[ +<?php +$result = sesam_query ("SELECT * FROM phone\n". + " WHERE LASTNAME='".strtoupper($name)."'\n". + " ORDER BY FIRSTNAME", 1); if (!$result) { ... error ... } // print the table: -print "<TABLE BORDER>\n"; -while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { - print " <TR>\n"; - print " <TD>".htmlspecialchars ($row["firstname"])."</TD>\n"; - print " <TD>".htmlspecialchars ($row["lastname"])."</TD>\n"; - print " <TD>".htmlspecialchars ($row["phoneno"])."</TD>\n"; - print " </TR>\n"; +print "<TABLE BORDER>\n"; +while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { + print " <TR>\n"; + print " <TD>".htmlspecialchars ($row["firstname"])."</TD>\n"; + print " <TD>".htmlspecialchars ($row["lastname"])."</TD>\n"; + print " <TD>".htmlspecialchars ($row["phoneno"])."</TD>\n"; + print " </TR>\n"; } -print "</TABLE>\n"; +print "</TABLE>\n"; sesam_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> Index: phpdoc/en/functions/session.xml diff -u phpdoc/en/functions/session.xml:1.55 phpdoc/en/functions/session.xml:1.56 --- phpdoc/en/functions/session.xml:1.55 Sat Nov 10 16:49:40 2001 +++ phpdoc/en/functions/session.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.55 $ --> +<!-- $Revision: 1.56 $ --> <reference id="ref.session"> <title>Session handling functions</title> <titleabbrev>Sessions</titleabbrev> @@ -69,10 +69,12 @@ enabled </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register("count"); $HTTP_SESSION_VARS["count"]++; -?> +?> +]]> </programlisting> </example> </para> @@ -89,10 +91,12 @@ enabled </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register("count"); $count++; -?> +?> +]]> </programlisting> </example> </para> @@ -142,19 +146,21 @@ <example> <title>Counting the number of hits of a single user</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php session_register ("count"); $count++; -?> +?> Hello visitor, you have seen this page <?php echo $count; ?> times.<p> -<php? -# the <?=SID?> is necessary to preserve the session id +<?php +# the <?=SID?> is necessary to preserve the session id # in the case that the user has disabled cookies -?> +?> -To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +]]> </programlisting> </example> </para> @@ -421,14 +427,16 @@ <example> <title><function>session_name</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php # set the session name to WebsiteID $previous_name = session_name ("WebsiteID"); -echo "The previous session name was $previous_name<p>"; -?> +echo "The previous session name was $previous_name<p>"; +?> +]]> </programlisting> </example> <note> @@ -846,8 +854,8 @@ <function>session_set_save_handler</function> example </title> <programlisting role="php"> -<?php - +<![CDATA[ +<?php function open ($save_path, $session_name) { global $sess_save_path, $sess_session_name; @@ -906,7 +914,8 @@ // proceed to use sessions normally -?> +?> +]]> </programlisting> </example> </para> @@ -964,15 +973,17 @@ <example> <title><function>session_cache_limiter</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php # set the cache limiter to 'private' session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); -echo "The cache limiter is now set to $cache_limiter<p>"; -?> +echo "The cache limiter is now set to $cache_limiter<p>"; +?> +]]> </programlisting> </example> <note> Index: phpdoc/en/functions/shmop.xml diff -u phpdoc/en/functions/shmop.xml:1.9 phpdoc/en/functions/shmop.xml:1.10 --- phpdoc/en/functions/shmop.xml:1.9 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/shmop.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <reference id="ref.shmop"> <title>Shared Memory Functions</title> <titleabbrev>shmop</titleabbrev> @@ -24,7 +24,8 @@ <example> <title>Shared Memory Operations Overview</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // Create 100 byte shared memory block with system id if 0xff3 $shm_id = shmop_open(0xff3, "c", 0644, 100); @@ -55,7 +56,8 @@ } shmop_close($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -114,9 +116,11 @@ <example> <title>Create a new shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_id = shmop_open(0x0fff, "c", 0644, 100); -?> +?> +]]> </programlisting> </example> </para> @@ -153,9 +157,11 @@ <example> <title>Reading shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_data = shmop_read($shm_id, 0, 50); -?> +?> +]]> </programlisting> </example> </para> @@ -194,9 +200,11 @@ <example> <title>Writing to shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_bytes_written = shmop_write($shm_id, $my_string, 0); -?> +?> +]]> </programlisting> </example> </para> @@ -235,9 +243,11 @@ <example> <title>Getting the size of the shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $shm_size = shmop_size($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -273,9 +283,11 @@ <example> <title>Deleting shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php shmop_delete($shm_id); -?> +?> +]]> </programlisting> </example> </para> @@ -310,9 +322,11 @@ <example> <title>Closing shared memory block</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php shmop_close($shm_id); -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/snmp.xml diff -u phpdoc/en/functions/snmp.xml:1.16 phpdoc/en/functions/snmp.xml:1.17 --- phpdoc/en/functions/snmp.xml:1.16 Mon Nov 12 12:09:12 2001 +++ phpdoc/en/functions/snmp.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.16 $ --> +<!-- $Revision: 1.17 $ --> <reference id="ref.snmp"> <title>SNMP functions</title> <titleabbrev>SNMP</titleabbrev> @@ -16,8 +16,10 @@ #define line. It should look like this afterwards:</simpara> <para> - <programlisting> + <programlisting role="c"> +<![CDATA[ #define NO_ZEROLENGTH_COMMUNITY 1 +]]> </programlisting> </para> @@ -60,7 +62,9 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); +]]> </programlisting> </informalexample> </para> @@ -139,7 +143,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $a = snmpwalk("127.0.0.1", "public", ""); +]]> </programlisting> </informalexample></para> @@ -150,9 +156,11 @@ <informalexample> <programlisting role="php"> -for ($i=0; $i<count($a); $i++) { +<![CDATA[ +for ($i=0; $i < count($a); $i++) { echo $a[$i]; } +]]> </programlisting> </informalexample></para> @@ -204,7 +212,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $a = snmpwalkoid("127.0.0.1", "public", ""); +]]> </programlisting> </informalexample></para> @@ -215,9 +225,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ for (reset($a); $i = key($a); next($a)) { - echo "$i: $a[$i]<br>\n"; + echo "$i: $a[$i]<br>\n"; } +]]> </programlisting> </informalexample></para> @@ -246,7 +258,9 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $quickprint = snmp_get_quick_print(); +]]> </programlisting> </informalexample></para> @@ -297,12 +311,14 @@ <informalexample> <programlisting role="php"> +<![CDATA[ snmp_set_quick_print(0); $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1"); -echo "$a<BR>\n"; +echo "$a<BR>\n"; snmp_set_quick_print(1); $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1"); -echo "$a<BR>\n"; +echo "$a<BR>\n"; +]]> </programlisting> </informalexample></para> Index: phpdoc/en/functions/sockets.xml diff -u phpdoc/en/functions/sockets.xml:1.23 phpdoc/en/functions/sockets.xml:1.24 --- phpdoc/en/functions/sockets.xml:1.23 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/sockets.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.sockets"> <title>Socket functions</title> <titleabbrev>Sockets</titleabbrev> @@ -48,7 +48,8 @@ side, and echoed back to you. To disconnect, enter 'quit'. </para> <programlisting role="php"> -<?php +<![CDATA[ +<?php error_reporting (E_ALL); /* Allow the script to hang around waiting for connections. */ @@ -57,27 +58,27 @@ $address = '192.168.1.53'; $port = 10000; -if (($sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { +if (($sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { echo "socket() failed: reason: " . strerror ($sock) . "\n"; } -if (($ret = bind ($sock, $address, $port)) < 0) { +if (($ret = bind ($sock, $address, $port)) < 0) { echo "bind() failed: reason: " . strerror ($ret) . "\n"; } -if (($ret = listen ($sock, 5)) < 0) { +if (($ret = listen ($sock, 5)) < 0) { echo "listen() failed: reason: " . strerror ($ret) . "\n"; } do { - if (($msgsock = accept_connect($sock)) < 0) { + if (($msgsock = accept_connect($sock)) < 0) { echo "accept_connect() failed: reason: " . strerror ($msgsock) . "\n"; break; } do { $buf = ''; $ret = read ($msgsock, $buf, 2048); - if ($ret < 0) { + if ($ret < 0) { echo "read() failed: reason: " . strerror ($ret) . "\n"; break 2; } @@ -98,6 +99,7 @@ close ($sock); ?> +]]> </programlisting> </example> </para> @@ -110,10 +112,11 @@ and exits. </para> <programlisting> -<?php +<![CDATA[ +<?php error_reporting (E_ALL); -echo "<h2>TCP/IP Connection</h2>\n"; +echo "<h2>TCP/IP Connection</h2>\n"; /* Get the port for the WWW service. */ $service_port = getservbyname ('www', 'tcp'); @@ -123,7 +126,7 @@ /* Create a TCP/IP socket. */ $socket = socket (AF_INET, SOCK_STREAM, 0); -if ($socket < 0) { +if ($socket < 0) { echo "socket() failed: reason: " . strerror ($socket) . "\n"; } else { "socket() successful: " . strerror ($socket) . "\n"; @@ -131,7 +134,7 @@ echo "Attempting to connect to '$address' on port '$service_port'..."; $result = connect ($socket, $address, $service_port); -if ($result < 0) { +if ($result < 0) { echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n"; } else { echo "OK.\n"; @@ -153,6 +156,7 @@ close ($socket); echo "OK.\n\n"; ?> +]]> </programlisting> </example> </para> @@ -546,7 +550,8 @@ <example> <title><function>strerror</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (($socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { echo "socket() failed: reason: " . strerror ($socket) . "\n"; } @@ -555,6 +560,7 @@ echo "bind() failed: reason: " . strerror ($ret) . "\n"; } ?> +]]> </programlisting> <para> The expected output from the above example (assuming the script Index: phpdoc/en/functions/strings.xml diff -u phpdoc/en/functions/strings.xml:1.126 phpdoc/en/functions/strings.xml:1.127 --- phpdoc/en/functions/strings.xml:1.126 Wed Nov 21 14:13:24 2001 +++ phpdoc/en/functions/strings.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.126 $ --> +<!-- $Revision: 1.127 $ --> <reference id="ref.strings"> <title>String functions</title> <titleabbrev>Strings</titleabbrev> @@ -54,7 +54,9 @@ <example> <title><function>addcslashes</function> example</title> <programlisting role="php"> +<![CDATA[ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); +]]> </programlisting> </example> </para> @@ -64,9 +66,11 @@ characters that you set as the start and end of the range. <informalexample> <programlisting role="php"> +<![CDATA[ echo addcslashes('foo[]', 'A..z'); // All upper and lower-case letters will be escaped // ... but so will the [\]^_` and space characters. +]]> </programlisting> </informalexample> Also, if the first character in a range has a lower ASCII value @@ -76,11 +80,13 @@ ASCII value for a character. <informalexample> <programlisting role="php"> +<![CDATA[ echo addcslashes("zoo['.']", 'z..A'); /* output: \zoo['\.'] */ +]]> </programlisting> </informalexample> <note> @@ -192,11 +198,13 @@ <example> <title><function>chr</function> example</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -242,9 +250,11 @@ <example> <title><function>chunk_split</function> example</title> <programlisting role="php"> +<![CDATA[ # format $data using RFC 2045 semantics $new_string = chunk_split(base64_encode($data)); +]]> </programlisting> </example> This function is significantly faster than @@ -523,7 +533,8 @@ <example> <title><function>echo</function> examples</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php echo "Hello World"; echo "This spans @@ -554,6 +565,7 @@ ($some_var) ? print('true'): print('false'); // print is a function echo $some_var ? 'true': 'false'; // changing the statement around ?> +]]> </programlisting> </example> </para> @@ -562,7 +574,9 @@ can immediately follow the opening tag with an equals sign. <informalexample> <programlisting role="php"> -I have <?=$foo?> foo. +<![CDATA[ +I have <?=$foo?> foo. +]]> </programlisting> </informalexample> </para> @@ -617,8 +631,10 @@ <example> <title><function>explode</function> example</title> <programlisting role="php"> +<![CDATA[ $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); +]]> </programlisting> </example> </para> @@ -679,9 +695,11 @@ <example> <title>Translation Table Example</title> <programlisting role="php"> +<![CDATA[ $trans = get_html_translation_table(HTML_ENTITIES); -$str = "Hallo & <Frau> & Krämer"; +$str = "Hallo & <Frau> & Krämer"; $encoded = strtr($str, $trans); +]]> </programlisting> </example> The <literal>$encoded</literal> variable will now contain: "Hallo @@ -694,8 +712,10 @@ the direction of the translation. <informalexample> <programlisting role="php"> +<![CDATA[ $trans = array_flip($trans); $original = strtr($str, $trans); +]]> </programlisting> </informalexample> The content of <literal>$original</literal> would be: "Hallo & @@ -739,9 +759,11 @@ <example> <title>Meta Tags Example</title> <programlisting role="html"> -<meta name="author" content="name"> -<meta name="tags" content="php3 documentation"> -</head> <!-- parsing stops here --> +<![CDATA[ +<meta name="author" content="name"> +<meta name="tags" content="php3 documentation"> +</head> <!-- parsing stops here --> +]]> </programlisting> </example> (pay attention to line endings - PHP uses a native function to @@ -947,7 +969,9 @@ <example> <title><function>htmlspecialchars</function> example</title> <programlisting role="php"> -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +<![CDATA[ +$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +]]> </programlisting> </example> </para> @@ -989,7 +1013,9 @@ <example> <title><function>implode</function> example</title> <programlisting role="php"> +<![CDATA[ $colon_separated = implode(":", $array); +]]> </programlisting> </example> </para> @@ -1334,11 +1360,12 @@ <example> <title><function>localeconv</function> example</title> <programlisting role="php"> +<![CDATA[ setlocale(LC_ALL, "en_US"); $locale_info = localeconv(); -echo "<PRE>\n"; +echo "<PRE>\n"; echo "--------------------------------------------\n"; echo " Monetary information for current locale: \n"; echo "--------------------------------------------\n\n"; @@ -1357,7 +1384,8 @@ 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"; +echo "</PRE>\n"; +]]> </programlisting> </example> <para> @@ -1596,9 +1624,11 @@ <example> <title><function>ord</function> example</title> <programlisting role="php"> +<![CDATA[ if (ord($str) == 10) { echo "The first character of \$str is a line feed.\n"; } +]> </programlisting> </example> </para> @@ -1639,11 +1669,13 @@ <example> <title>Using <function>parse_str</function></title> <programlisting role="php"> -$str = "first=value&second[]=this+works&second[]=another"; +<![CDATA[ +$str = "first=value&second[]=this+works&second[]=another"; parse_str($str); echo $first; /* prints "value" */ echo $second[0]; /* prints "this works" */ echo $second[1]; /* prints "another" */ +]]> </programlisting> </example> </para> @@ -1890,12 +1922,14 @@ <example> <title><function>sscanf</function> Example</title> <programlisting role="php"> +<![CDATA[ // 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> If optional parameters are passed, the function will return the @@ -1904,13 +1938,15 @@ <example> <title><function>sscanf</function> - using optional parameters</title> <programlisting role="php"> +<![CDATA[ // get author info and generate DocBook entry $auth = "24\tLewis Carroll"; $n = sscanf($auth,"%d\t%s %s", &$id, &$first, &$last); -echo "<author id='$id'> - <firstname>$first</firstname> - <surname>$last</surname> -</author>\n"; +echo "<author id='$id'> + <firstname>$first</firstname> + <surname>$last</surname> +</author>\n"; +]]> </programlisting> </example> </para> @@ -2062,12 +2098,14 @@ <example> <title>Soundex Examples</title> <programlisting role="php"> +<![CDATA[ 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> @@ -2201,8 +2239,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "There are %d monkeys in the %s"; printf($format,$num,$location); +]]> </programlisting> </example> This might output, "There are 5 monkeys in the tree". But @@ -2212,8 +2252,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "The %s contains %d monkeys"; printf($format,$num,$location); +]]> </programlisting> </example> We now have a problem. The order of the placeholders in the @@ -2224,8 +2266,10 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $format = "The %2\$s contains %1\$d monkeys"; printf($format,$num,$location); +]]> </programlisting> </example> An added benefit here is that you can repeat the placeholders without @@ -2233,9 +2277,11 @@ <example> <title>Argument swapping</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2251,18 +2297,22 @@ <example> <title><function>sprintf</function>: zero-padded integers</title> <programlisting role="php"> +<![CDATA[ $isodate = sprintf("%04d-%02d-%02d", $year, $month, $day); +]]> </programlisting> </example> <example> <title><function>sprintf</function>: formatting currency</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2333,11 +2383,13 @@ <example> <title><function>strcasecmp</function> example</title> <programlisting role="php"> +<![CDATA[ $var1 = "Hello"; $var2 = "hello"; if (!strcasecmp($var1, $var2)) { echo '$var1 is equal to $var2 in a case-insensitive string comparison'; } +]]> </programlisting> </example> </para> @@ -2511,7 +2563,9 @@ <example> <title><function>strip_tags</function> example</title> <programlisting role="php"> -$string = strip_tags($string, '<a><b><i><u>'); +<![CDATA[ +$string = strip_tags($string, '<a><b><i><u>'); +]]> </programlisting> </example> </para> @@ -2665,6 +2719,7 @@ below: <informalexample> <programlisting> +<![CDATA[ $arr1 = $arr2 = array("img12.png","img10.png","img2.png","img1.png"); echo "Standard string comparison\n"; usort($arr1,"strcmp"); @@ -2672,29 +2727,32 @@ echo "\nNatural order string comparison\n"; usort($arr2,"strnatcmp"); print_r($arr2); +]]> </programlisting> </informalexample> The code above will generate the following output: <informalexample> - <programlisting> + <screen> +<![CDATA[ Standard string comparison Array ( - [0] => img1.png - [1] => img10.png - [2] => img12.png - [3] => img2.png + [0] => img1.png + [1] => img10.png + [2] => img12.png + [3] => img2.png ) Natural order string comparison Array ( - [0] => img1.png - [1] => img2.png - [2] => img10.png - [3] => img12.png + [0] => img1.png + [1] => img2.png + [2] => img10.png + [3] => img12.png ) - </programlisting> +]]> + </screen> </informalexample> For more information see: Martin Pool's <ulink url="&url.strnatcmp;">Natural Order String Comparison</ulink> @@ -2853,10 +2911,12 @@ <example> <title><function>str_pad</function> example</title> <programlisting role="php"> +<![CDATA[ $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> </para> @@ -2899,6 +2959,7 @@ the difference: <informalexample> <programlisting role="php"> +<![CDATA[ // in PHP 4.0b3 and newer: $pos = strpos($mystring, "b"); if ($pos === false) { // note: three equal signs @@ -2907,9 +2968,10 @@ // in versions older than 4.0b3: $pos = strpos($mystring, "b"); -if (is_string($pos) && !$pos) { +if (is_string($pos) && !$pos) { // not found... } +]]> </programlisting> </informalexample> </para> @@ -2968,12 +3030,14 @@ <example> <title><function>strrchr</function> example</title> <programlisting role="php"> +<![CDATA[ // 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> </para> @@ -3006,7 +3070,9 @@ <example> <title><function>str_repeat</function> example</title> <programlisting role="php"> +<![CDATA[ echo str_repeat("-=", 10); +]]> </programlisting> </example> <para> @@ -3038,9 +3104,11 @@ <example> <title>Reversing a string with <function>strrev</function></title> <programlisting role="php"> -<php +<![CDATA[ +<php echo strrev("Hello world!"); // outputs "!dlrow olleH" -?> +?> +]]> </programlisting> </example> </para> @@ -3080,6 +3148,7 @@ the difference: <informalexample> <programlisting role="php"> +<![CDATA[ // in PHP 4.0b3 and newer: $pos = strrpos($mystring, "b"); if ($pos === false) { // note: three equal signs @@ -3088,9 +3157,10 @@ // in versions older than 4.0b3: $pos = strrpos($mystring, "b"); -if (is_string($pos) && !$pos) { +if (is_string($pos) && !$pos) { // not found... } +]]> </programlisting> </informalexample> </para> @@ -3133,7 +3203,9 @@ The line of code: <informalexample> <programlisting role="php"> +<![CDATA[ $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 @@ -3182,9 +3254,11 @@ <example> <title><function>strstr</function> example</title> <programlisting role="php"> +<![CDATA[ $email = 'sterling@designmultimedia.com'; $domain = strstr($email, '@'); print $domain; // prints @designmultimedia.com +]]> </programlisting> </example> </para> @@ -3218,12 +3292,14 @@ <example> <title><function>strtok</function> example</title> <programlisting role="php"> +<![CDATA[ $string = "This is an example string"; $tok = strtok($string," "); while ($tok) { - echo "Word=$tok<br>"; + echo "Word=$tok<br>"; $tok = strtok(" "); } +]]> </programlisting> </example> </para> @@ -3273,9 +3349,11 @@ <example> <title><function>strtolower</function> example</title> <programlisting role="php"> +<![CDATA[ $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> <para> @@ -3311,9 +3389,11 @@ <example> <title><function>strtoupper</function> example</title> <programlisting role="php"> +<![CDATA[ $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> <para> @@ -3377,7 +3457,9 @@ <example> <title><function>str_replace</function> example</title> <programlisting role="php"> -$bodytag = str_replace("%body%", "black", "<body text=%body%>"); +<![CDATA[ +$bodytag = str_replace("%body%", "black", "<body text=%body%>"); +]]> </programlisting> </example> </para> @@ -3425,7 +3507,9 @@ <example> <title><function>strtr</function> example</title> <programlisting role="php"> +<![CDATA[ $addr = strtr($addr, "äåö", "aao"); +]]> </programlisting> </example> </para> @@ -3442,8 +3526,10 @@ Examples: <informalexample> <programlisting role="php"> -$trans = array("hello" => "hi", "hi" => "hello"); +<![CDATA[ +$trans = array("hello" => "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans) . "\n"; +]]> </programlisting> </informalexample> This will show: "hello all, I said hi", @@ -3494,8 +3580,10 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", 1); // returns "bcdef" $rest = substr("abcdef", 1, 3); // returns "bcd" +]]> </programlisting> </informalexample> </para> @@ -3507,9 +3595,11 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", -1); // returns "f" $rest = substr("abcdef", -2); // returns "ef" $rest = substr("abcdef", -3, 1); // returns "d" +]]> </programlisting> </informalexample> </para> @@ -3533,7 +3623,9 @@ Examples: <informalexample> <programlisting role="php"> +<![CDATA[ $rest = substr("abcdef", 1, -1); // returns "bcde" +]]> </programlisting> </informalexample> </para> @@ -3568,7 +3660,9 @@ <example> <title><function>substr_count</function> example</title> <programlisting> +<![CDATA[ print substr_count("This is a test", "is"); // prints out 2 +]]> </programlisting> </example> </para> @@ -3624,24 +3718,26 @@ <example> <title><function>substr_replace</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $var = 'ABCDEFGH:/MNRPQR/'; -echo "Original: $var<hr>\n"; +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> </para> @@ -3788,12 +3884,14 @@ <example> <title><function>ucfirst</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! +]]> </programlisting> </example> </para> @@ -3826,12 +3924,14 @@ <example> <title><function>ucwords</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! +]]> </programlisting> </example> <note> @@ -3965,10 +4065,12 @@ <example> <title><function>wordwrap</function> example</title> <programlisting role="php"> +<![CDATA[ $text = "The quick brown fox jumped over the lazy dog."; $newtext = wordwrap( $text, 20 ); echo "$newtext\n"; +]]> </programlisting> </example> </para> @@ -3977,20 +4079,24 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ The quick brown fox jumped over the lazy dog. - </programlisting> +]]> + </screen> </informalexample> </para> <para> <example> <title><function>wordwrap</function> example</title> <programlisting role="php"> +<![CDATA[ $text = "A very long woooooooooooord."; $newtext = wordwrap( $text, 8, "\n", 1); echo "$newtext\n"; +]]> </programlisting> </example> </para> @@ -3999,12 +4105,14 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ A very long wooooooo ooooord. - </programlisting> +]]> + </screen> </informalexample> </para> <para> Index: phpdoc/en/functions/swf.xml diff -u phpdoc/en/functions/swf.xml:1.24 phpdoc/en/functions/swf.xml:1.25 --- phpdoc/en/functions/swf.xml:1.24 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/swf.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.24 $ --> +<!-- $Revision: 1.25 $ --> <reference id="ref.swf"> <title>Shockwave Flash functions</title> <titleabbrev>SWF</titleabbrev> @@ -25,7 +25,8 @@ <example> <title>SWF example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php swf_openfile ("test.swf", 256, 256, 30, 1, 1, 1); swf_ortho2 (-100, 100, -100, 100); swf_defineline (1, -70, 0, 70, 0, .2); @@ -43,7 +44,7 @@ swf_placeobject (11, 60); swf_popmatrix (); -for ($i = 0; $i < 30; $i++) { +for ($i = 0; $i < 30; $i++) { $p = $i/(30-1); swf_pushmatrix (); swf_scale (1-($p*.9), 1, 1); @@ -58,7 +59,7 @@ swf_showframe (); } -for ($i = 0; $i < 30; $i++) { +for ($i = 0; $i < 30; $i++) { swf_removeobject (50); if (($i%4) == 0) { swf_showframe (); @@ -70,7 +71,8 @@ swf_enddoaction (); swf_closefile (); -?> +?> +]]> </programlisting> </example> </para> @@ -172,7 +174,8 @@ and saving it in a database </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // The $text variable is submitted by the // user @@ -236,7 +239,8 @@ @mysql_free_result ($sth); @mysql_close ($dbh); } -> +?> +]]> </programlisting> </example> </para> @@ -1777,6 +1781,7 @@ <function>swf_addbuttonrecord</function> function example </title> <programlisting role="php"> +<![CDATA[ swf_startButton ($objid, TYPE_MENUBUTTON); swf_addButtonRecord (BSDown|BSOver, $buttonImageId, 340); swf_onCondition (MenuEnter); @@ -1784,6 +1789,7 @@ swf_onCondition (MenuExit); swf_actionGetUrl ("", "_level1"); swf_endButton (); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/uodbc.xml diff -u phpdoc/en/functions/uodbc.xml:1.26 phpdoc/en/functions/uodbc.xml:1.27 --- phpdoc/en/functions/uodbc.xml:1.26 Sat Nov 10 16:49:41 2001 +++ phpdoc/en/functions/uodbc.xml Wed Nov 21 18:05:18 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.26 $ --> +<!-- $Revision: 1.27 $ --> <reference id="ref.odbc"> <title>Unified ODBC functions</title> <titleabbrev>ODBC</titleabbrev> @@ -512,15 +512,19 @@ <example> <title><function>odbc_fetch_into</function> pre 4.0.6 example </title> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $my_array); +]]> </programlisting> <para> or </para> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $row, $my_array); $rc = odbc_fetch_into($res_id, 1, $my_array); +]]> </programlisting> </example> </para> @@ -536,14 +540,18 @@ <example> <title><function>odbc_fetch_into</function> 4.0.6 example</title> <programlisting role="php"> +<![CDATA[ $rc = odbc_fetch_into($res_id, $my_array); +]]> </programlisting> <para> or </para> <programlisting role="php"> +<![CDATA[ $row = 1; $rc = odbc_fetch_into($res_id, $row, $my_array); +]]> </programlisting> </example> </para> @@ -959,8 +967,10 @@ the column number of the field you want; or it can be a string containing the name of the field. For example: <informalexample><programlisting> +<![CDATA[ $item_3 = odbc_result ($Query_ID, 3); $item_val = odbc_result ($Query_ID, "val"); +]]> </programlisting> </informalexample> </para> @@ -1105,6 +1115,7 @@ <example> <title>ODBC Setoption Examples</title> <programlisting role="php"> +<![CDATA[ // 1. Option 102 of SQLSetConnectOption() is SQL_AUTOCOMMIT. // Value 1 of SQL_AUTOCOMMIT is SQL_AUTOCOMMIT_ON. // This example has the same effect as @@ -1118,6 +1129,7 @@ $result = odbc_prepare ($conn, $sql); odbc_setoption ($result, 2, 0, 30); odbc_execute ($result); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/url.xml diff -u phpdoc/en/functions/url.xml:1.19 phpdoc/en/functions/url.xml:1.20 --- phpdoc/en/functions/url.xml:1.19 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/url.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <reference id="ref.url"> <title>URL Functions</title> <titleabbrev>URLs</titleabbrev> @@ -138,16 +138,20 @@ <example> <title><function>rawurlencode</function> example 1</title> <programlisting role="php"> -echo '<a href="ftp://user:', rawurlencode('foo @+%/'), +<![CDATA[ +echo '<a href="ftp://user:', rawurlencode('foo @+%/'), '@ftp.my.com/x.txt">'; +]]> </programlisting> </example> Or, if you pass information in a PATH_INFO component of the URL: <example> <title><function>rawurlencode</function> example 2</title> <programlisting role="php"> -echo '<a href="http://x.com/department_list_script/', +<![CDATA[ +echo '<a href="http://x.com/department_list_script/', rawurlencode('sales and marketing/Miami'), '">'; +]]> </programlisting> </example> </para> @@ -178,14 +182,16 @@ <example> <title><function>urldecode</function> example</title> <programlisting role="php"> -$a = split('&', $QUERY_STRING); +<![CDATA[ +$a = split('&', $QUERY_STRING); $i = 0; -while ($i < count($a)) { +while ($i < count($a)) { $b = split('=', $a[$i]); echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])), ' is ', htmlspecialchars(urldecode($b[1])), "<br>"; $i++; } +]]> </programlisting> </example> </para> @@ -226,7 +232,9 @@ <example> <title><function>urlencode</function> example</title> <programlisting role="php"> -echo '<a href="mycgi?foo=', urlencode($userinput), '">'; +<![CDATA[ +echo '<a href="mycgi?foo=', urlencode($userinput), '">'; +]]> </programlisting> </example> </para> @@ -247,7 +255,9 @@ <example> <title><function>urlencode/htmlentities</function> example</title> <programlisting role="php"> -echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'; +<![CDATA[ +echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'; +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/var.xml diff -u phpdoc/en/functions/var.xml:1.76 phpdoc/en/functions/var.xml:1.77 --- phpdoc/en/functions/var.xml:1.76 Tue Nov 20 20:48:33 2001 +++ phpdoc/en/functions/var.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.76 $ --> +<!-- $Revision: 1.77 $ --> <reference id="ref.variables"> <title>Variable Functions</title> <titleabbrev>Variables</titleabbrev> @@ -56,6 +56,7 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $var = 0; if (empty($var)) { // evaluates true @@ -65,6 +66,7 @@ if (!isset($var)) { // evaluates false echo '$var is not set at all'; } +]]> </programlisting> </informalexample> @@ -103,9 +105,11 @@ <function>floatval</function> on arrays or objects. <informalexample> <programlisting role="php"> +<![CDATA[ $var = '122.34343The'; $float_value_of_var = floatval ($var); print $float_value_of_var; // prints 122.34343 +]]> </programlisting> </informalexample> </para> @@ -226,6 +230,7 @@ variables. <informalexample> <programlisting role="php"> +<![CDATA[ $b = array(1,1,2,3,5,8); $arr = get_defined_vars(); @@ -245,6 +250,7 @@ // print all the available keys for the arrays of variables print_r(array_keys(get_defined_vars())); +]]> </programlisting> </informalexample> </para> @@ -276,6 +282,7 @@ generates an error. <informalexample> <programlisting role="php"> +<![CDATA[ $c = mysql_connect(); echo get_resource_type($c)."\n"; // prints: mysql link @@ -287,6 +294,7 @@ $doc = new_xmldoc("1.0"); echo get_resource_type($doc->doc)."\n"; // prints: domxml document +]]> </programlisting> </informalexample> </para> @@ -338,9 +346,11 @@ </note> <informalexample> <programlisting role="php"> +<![CDATA[ // This will import GET and POST vars // with an "rvar_" prefix import_request_variables("gP", "rvar_"); +]]> </programlisting> </informalexample> <simpara> @@ -715,6 +725,7 @@ For example: <informalexample> <programlisting role="php"> +<![CDATA[ <!-- TODO: better example, this one can be quite misleading for unexperienced programmers --> function show_var($var) { @@ -740,6 +751,7 @@ // [2]=> // string(10) "ferredoxin" // } +]]> </programlisting> </informalexample> </para> @@ -826,6 +838,7 @@ is not equivalent to the PHP &null; constant. <informalexample> <programlisting role="php"> +<![CDATA[ $a = "test"; echo isset ($a); // TRUE @@ -834,6 +847,7 @@ $foo = NULL; print isset ($foo); // FALSE +]]> </programlisting> </informalexample> </para> @@ -880,10 +894,12 @@ <para> <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php $a = array (1, 2, array ("a", "b", "c")); print_r ($a); ?> +]]> </programlisting> </informalexample> </para> @@ -960,6 +976,7 @@ <example> <title><function>serialize</function> example</title> <programlisting role="php"> +<![CDATA[ // $session_data contains a multi-dimensional array with session // information for the current user. We use serialize() to store // it in a database at the end of the request. @@ -971,10 +988,11 @@ if (!odbc_execute ($stmt, &$sqldata)) { $stmt = odbc_prepare($conn, "INSERT INTO sessions (id, data) VALUES(?, ?)"); - if (!odbc_execute($stmt, &$sqldata)) { + if (!odbc_execute($stmt, &$sqldata)) { /* Something went wrong. Bitch, whine and moan. */ } } +]]> </programlisting> </example> </para> @@ -1051,11 +1069,13 @@ <example> <title><function>settype</function> example</title> <programlisting role="php"> +<![CDATA[ $foo = "5bar"; // string $bar = true; // boolean settype($foo, "integer"); // $foo is now 5 (integer) settype($bar, "string"); // $bar is now "1" (string) +]]> </programlisting> </example> </para> @@ -1136,6 +1156,7 @@ <example> <title><function>unserialize</function> example</title> <programlisting role="php"> +<![CDATA[ // Here, we use unserialize() to load session data from a database // into $session_data. This example complements the one described // with <function>serialize</function>. @@ -1154,6 +1175,7 @@ $session_data = array(); } } +]]> </programlisting> </example> </para> @@ -1191,6 +1213,7 @@ <example> <title><function>unset</function> example</title> <programlisting role="php"> +<![CDATA[ // destroy a single variable unset ($foo); @@ -1199,6 +1222,7 @@ // destroy more than one variable unset ($foo1, $foo2, $foo3); +]]> </programlisting> </example> </para> @@ -1214,6 +1238,7 @@ <function>unset</function> was called. <informalexample> <programlisting role="php"> +<![CDATA[ function destroy_foo() { global $foo; unset($foo); @@ -1222,13 +1247,16 @@ $foo = 'bar'; destroy_foo(); echo $foo; +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ bar - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1239,7 +1267,8 @@ was called. <informalexample> <programlisting role="php"> -function foo(&$bar) { +<![CDATA[ +function foo(&$bar) { unset($bar); $bar = "blah"; } @@ -1249,14 +1278,17 @@ foo($bar); echo "$bar\n"; +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ something something - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1265,6 +1297,7 @@ static variable, rather than the static variable itself. <informalexample> <programlisting role="php"> +<![CDATA[ function foo() { static $a; $a++; @@ -1276,27 +1309,32 @@ foo(); foo(); foo(); +]]> </programlisting> </informalexample> The above example would output: <informalexample> - <programlisting> + <screen> +<![CDATA[ 1 2 3 - </programlisting> +]]> + </screen> </informalexample> </para> <para> If you would like to <function>unset</function> a global variable inside of a function, you can use the <parameter>$GLOBALS</parameter> array to do so: <informalexample> <programlisting role="php"> +<![CDATA[ function foo() { unset($GLOBALS['bar']); } $bar = "something"; foo(); +]]> </programlisting> </informalexample> </para> @@ -1340,8 +1378,9 @@ <para> <informalexample> <programlisting role="php"> -<pre> -<?php +<![CDATA[ +<pre> +<?php $a = array (1, 2, array ("a", "b", "c")); var_dump ($a); @@ -1372,8 +1411,9 @@ bool(true) */ -?> -</pre> +?>; +</pre> +]]> </programlisting> </informalexample> </para> Index: phpdoc/en/functions/wddx.xml diff -u phpdoc/en/functions/wddx.xml:1.13 phpdoc/en/functions/wddx.xml:1.14 --- phpdoc/en/functions/wddx.xml:1.13 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/wddx.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <reference id="ref.wddx"> <title>WDDX Functions</title> <titleabbrev>WDDX</titleabbrev> @@ -24,9 +24,12 @@ <example> <title>Serializing a single value</title> <programlisting role="php"> -<?php +<![CDATA[ +</php> +<?php print wddx_serialize_value("PHP to WDDX packet example", "PHP packet"); -?> +?> +]]> </programlisting> </example> </para> @@ -34,15 +37,18 @@ This example will produce: <informalexample> <programlisting role="php"> -<wddxPacket version='1.0'><header comment='PHP packet'/><data> -<string>PHP to WDDX packet example</string></data></wddxPacket> +<![CDATA[ +<wddxPacket version='1.0'><header comment='PHP packet'/><data> +<string>PHP to WDDX packet example</string></data></wddxPacket> +]]> </programlisting> </informalexample> <example> <title>Using incremental packets</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $pi = 3.1415926; $packet_id = wddx_packet_start("PHP"); wddx_add_vars($packet_id, "pi"); @@ -53,19 +59,22 @@ $packet = wddx_packet_end($packet_id); print $packet; -?> +?> +]]> </programlisting> </example> </para> <para> This example will produce: <informalexample> - <programlisting role="php"> -<wddxPacket version='1.0'><header comment='PHP'/><data><struct> -<var name='pi'><number>3.1415926</number></var><var name='cities'> -<array length='3'><string>Austin</string><string>Novato</string> -<string>Seattle</string></array></var></struct></data></wddxPacket> - </programlisting> + <screen> +<![CDATA[ +<wddxPacket version='1.0'><header comment='PHP'/><data><struct> +<var name='pi'><number>3.1415926</number></var><var name='cities'> +<array length='3'><string>Austin</string><string>Novato</string> +<string>Seattle</string></array></var></struct></data></wddxPacket> +]]> + </screen> </informalexample> </para> </partintro> @@ -127,7 +136,7 @@ <example> <title>wddx_serialize_vars example</title> <programlisting> -<?php +<?php $a = 1; $b = 5.5; $c = array("blue", "orange", "violet"); @@ -135,18 +144,20 @@ $clvars = array("c", "d"); print wddx_serialize_vars("a", "b", $clvars); -?> +?> </programlisting> </example> </para> <para> The above example will produce: - <programlisting> -<wddxPacket version='1.0'><header/><data><struct><var name='a'><number>1</number></var> -<var name='b'><number>5.5</number></var><var name='c'><array length='3'> -<string>blue</string><string>orange</string><string>violet</string></array></var> -<var name='d'><string>colors</string></var></struct></data></wddxPacket> - </programlisting> + <screen> +<![CDATA[ +<wddxPacket version='1.0'><header/><data><struct><var name='a'><number>1</number></var> +<var name='b'><number>5.5</number></var><var name='c'><array length='3'> +<string>blue</string><string>orange</string><string>violet</string></array></var> +<var name='d'><string>colors</string></var></struct></data></wddxPacket> +]]> + </screen> </para> </refsect1> </refentry> Index: phpdoc/en/functions/xml.xml diff -u phpdoc/en/functions/xml.xml:1.20 phpdoc/en/functions/xml.xml:1.21 --- phpdoc/en/functions/xml.xml:1.20 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/xml.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <reference id="ref.xml"> <title>XML parser functions</title> <titleabbrev>XML</titleabbrev> @@ -25,9 +25,11 @@ Makefile that comes with expat does not build a library by default, you can use this make rule for that: <programlisting role="makefile"> +<![CDATA[ libexpat.a: $(OBJS) ar -rc $@ $(OBJS) ranlib $@ +]]> </programlisting> A source RPM package of expat can be found at <ulink url="&url.expat.rpm;">&url.expat.rpm;</ulink>. @@ -273,12 +275,13 @@ <example> <title>Show XML Element Structure</title> <programlisting role="php"> +<![CDATA[ $file = "data.xml"; $depth = array(); function startElement($parser, $name, $attrs) { global $depth; - for ($i = 0; $i < $depth[$parser]; $i++) { + for ($i = 0; $i < $depth[$parser]; $i++) { print " "; } print "$name\n"; @@ -304,6 +307,7 @@ } } xml_parser_free($xml_parser); +]]> </programlisting> </example> </para> @@ -320,24 +324,25 @@ course, this example will only work with a specific XML document type. <programlisting role="php"> +<![CDATA[ $file = "data.xml"; $map_array = array( - "BOLD" => "B", - "EMPHASIS" => "I", - "LITERAL" => "TT" + "BOLD" => "B", + "EMPHASIS" => "I", + "LITERAL" => "TT" ); function startElement($parser, $name, $attrs) { global $map_array; if ($htmltag = $map_array[$name]) { - print "<$htmltag>"; + print "<$htmltag>"; } } function endElement($parser, $name) { global $map_array; if ($htmltag = $map_array[$name]) { - print "</$htmltag>"; + print "</$htmltag>"; } } @@ -362,6 +367,7 @@ } } xml_parser_free($xml_parser); +]]> </programlisting> </para> </example> @@ -385,34 +391,35 @@ <example> <title>External Entity Example</title> <programlisting role="php"> +<![CDATA[ $file = "xmltest.xml"; function trustedFile($file) { // only trust local files owned by ourselves if (!eregi("^([a-z]+)://", $file) - && fileowner($file) == getmyuid()) { + && fileowner($file) == getmyuid()) { return true; } return false; } function startElement($parser, $name, $attribs) { - print "&lt;<font color=\"#0000cc\">$name</font>"; + print "<<font color=\"#0000cc\">$name</font>"; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { - print " <font color=\"#009900\">$k</font>=\"<font - color=\"#990000\">$v</font>\""; + print " <font color=\"#009900\">$k</font>=\"<font + color=\"#990000\">$v</font>\""; } } - print "&gt;"; + print ">"; } function endElement($parser, $name) { - print "&lt;/<font color=\"#0000cc\">$name</font>&gt;"; + print "</<font color=\"#0000cc\">$name</font>>"; } function characterData($parser, $data) { - print "<b>$data</b>"; + print "<b>$data</b>"; } function PIHandler($parser, $target, $data) { @@ -425,7 +432,7 @@ if (trustedFile($parser_file[$parser])) { eval($data); } else { - printf("Untrusted PHP code: <i>%s</i>", + printf("Untrusted PHP code: <i>%s</i>", htmlspecialchars($data)); } break; @@ -433,11 +440,11 @@ } function defaultHandler($parser, $data) { - if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - printf('<font color="#aa00aa">%s</font>', + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + printf('<font color="#aa00aa">%s</font>', htmlspecialchars($data)); } else { - printf('<font size="-1">%s</font>', + printf('<font size="-1">%s</font>', htmlspecialchars($data)); } } @@ -491,7 +498,7 @@ die("could not open XML input"); } -print "<pre>"; +print "<pre>"; while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d\n", @@ -499,11 +506,12 @@ xml_get_current_line_number($xml_parser))); } } -print "</pre>"; +print "</pre>"; print "parse complete\n"; xml_parser_free($xml_parser); -?> +?> +]]> </programlisting> </example> </para> @@ -511,33 +519,35 @@ <example> <title>xmltest.xml</title> <programlisting role="xml"> -<?xml version='1.0'?> -<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ -<!ENTITY plainEntity "FOO entity"> -<!ENTITY systemEntity SYSTEM "xmltest2.xml"> -]> -<chapter> - <TITLE>Title &plainEntity;</TITLE> - <para> - <informaltable> - <tgroup cols="3"> - <tbody> - <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> - <row><entry>a2</entry><entry>c2</entry></row> - <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> - </tbody> - </tgroup> - </informaltable> - </para> - &systemEntity; - <sect1 id="about"> - <title>About this Document</title> - <para> - <!-- this is a comment --> - <?php print 'Hi! This is PHP version '.phpversion(); ?> - </para> - </sect1> -</chapter> +<![CDATA[ +<?xml version='1.0'?> +<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ +<!ENTITY plainEntity "FOO entity"> +<!ENTITY systemEntity SYSTEM "xmltest2.xml"> +]> +<chapter> + <TITLE>Title &plainEntity;</TITLE> + <para> + <informaltable> + <tgroup cols="3"> + <tbody> + <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> + <row><entry>a2</entry><entry>c2</entry></row> + <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> + </tbody> + </tgroup> + </informaltable> + </para> + &systemEntity; + <sect1 id="about"> + <title>About this Document</title> + <para> + <!-- this is a comment --> + <?php print 'Hi! This is PHP version '.phpversion(); ?> + </para> + </sect1> +</chapter> +]]> </programlisting> </example> </para> @@ -546,15 +556,17 @@ <example> <title>xmltest2.xml</title> <programlisting role="xml"> -<?xml version="1.0"?> -<!DOCTYPE foo [ -<!ENTITY testEnt "test entity"> -]> -<foo> - <element attrib="value"/> - &testEnt; - <?php print "This is some more PHP code being executed."; ?> -</foo> +<![CDATA[ +<?xml version="1.0"?> +<!DOCTYPE foo [ +<!ENTITY testEnt "test entity"> +]> +<foo> + <element attrib="value"/> + &testEnt; + <?php print "This is some more PHP code being executed."; ?> +</foo> +]]> </programlisting> </example> </para> @@ -622,19 +634,20 @@ assumed to be methods of <parameter>object</parameter>. </para> <programlisting role="php"> -<?php +<![CDATA[ +<?php class xml { var $parser; function xml() { - $this->parser = xml_parser_create(); - xml_set_object($this->parser,&$this); - xml_set_element_handler($this->parser,"tag_open","tag_close"); - xml_set_character_data_handler($this->parser,"cdata"); + $this->parser = xml_parser_create(); + xml_set_object($this->parser,&$this); + xml_set_element_handler($this->parser,"tag_open","tag_close"); + xml_set_character_data_handler($this->parser,"cdata"); } function parse($data) { - xml_parse($this->parser,$data); + xml_parse($this->parser,$data); } function tag_open($parser,$tag,$attributes) { @@ -652,8 +665,9 @@ } // end of class xml $xml_parser = new xml(); -$xml_parser->parse("<A ID=\"hallo\">PHP</A>"); -?> +$xml_parser->parse("<A ID=\"hallo\">PHP</A>"); +?> +]]> </programlisting> </refsect1> </refentry> @@ -1653,8 +1667,9 @@ <literal>para</literal> tag, and then we parse this an print out the structures generated: <informalexample> - <programlisting> -$simple = "<para><note>simple note</note></para>"; + <programlisting role="php"> +<![CDATA[ +$simple = "<para><note>simple note</note></para>"; $p = xml_parser_create(); xml_parse_into_struct($p,$simple,$vals,$index); xml_parser_free($p); @@ -1662,23 +1677,25 @@ print_r($index); echo "\nVals array\n"; print_r($vals); +]]> </programlisting> </informalexample> When we run that code, the output will be: <informalexample> - <programlisting> + <screen> +<![CDATA[ Index array Array ( - [PARA] => Array + [PARA] => Array ( - [0] => 0 - [1] => 2 + [0] => 0 + [1] => 2 ) - [NOTE] => Array + [NOTE] => Array ( - [0] => 1 + [0] => 1 ) ) @@ -1686,30 +1703,31 @@ Vals array Array ( - [0] => Array + [0] => Array ( - [tag] => PARA - [type] => open - [level] => 1 + [tag] => PARA + [type] => open + [level] => 1 ) - [1] => Array + [1] => Array ( - [tag] => NOTE - [type] => complete - [level] => 2 - [value] => simple note + [tag] => NOTE + [type] => complete + [level] => 2 + [value] => simple note ) - [2] => Array + [2] => Array ( - [tag] => PARA - [type] => close - [level] => 1 + [tag] => PARA + [type] => close + [level] => 1 ) ) - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -1722,25 +1740,27 @@ representing a small database of aminoacids information: <example> <title>moldb.xml - small database of molecular information</title> - <programlisting> -<?xml version="1.0"?> -<moldb> - - <molecule> - <name>Alanine</name> - <symbol>ala</symbol> - <code>A</code> - <type>hydrophobic</type> - </molecule> - - <molecule> - <name>Lysine</name> - <symbol>lys</symbol> - <code>K</code> - <type>charged</type> - </molecule> + <programlisting role="xml"> +<![CDATA[ +<?xml version="1.0"?> +<moldb> + + <molecule> + <name>Alanine</name> + <symbol>ala</symbol> + <code>A</code> + <type>hydrophobic</type> + </molecule> + + <molecule> + <name>Lysine</name> + <symbol>lys</symbol> + <code>K</code> + <type>charged</type> + </molecule> -</moldb> +</moldb> +]]> </programlisting> </example> And some code to parse the document and generate the appropriate @@ -1751,7 +1771,8 @@ molecular objects </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php class AminoAcid { var $name; // aa name @@ -1760,8 +1781,8 @@ var $type; // hydrophobic, charged or neutral function AminoAcid ($aa) { - foreach ($aa as $k=>$v) - $this->$k = $aa[$k]; + foreach ($aa as $k=>$v) + $this->$k = $aa[$k]; } } @@ -1775,12 +1796,12 @@ xml_parser_free($parser); // loop through the structures - foreach ($tags as $key=>$val) { + foreach ($tags as $key=>$val) { if ($key == "molecule") { $molranges = $val; // each contiguous pair of array entries are the // lower and upper range for each molecule definition - for ($i=0; $i < count($molranges); $i+=2) { + for ($i=0; $i < count($molranges); $i+=2) { $offset = $molranges[$i] + 1; $len = $molranges[$i + 1] - $offset; $tdb[] = parseMol(array_slice($values, $offset, $len)); @@ -1793,7 +1814,7 @@ } function parseMol($mvalues) { - for ($i=0; $i < count($mvalues); $i++) + for ($i=0; $i < count($mvalues); $i++) $mol[$mvalues[$i]["tag"]] = $mvalues[$i]["value"]; return new AminoAcid($mol); } @@ -1802,7 +1823,8 @@ echo "** Database of AminoAcid objects:\n"; print_r($db); -?> +?> +]]> </programlisting> </example> After executing <filename>parsemoldb.php</filename>, the variable @@ -1810,28 +1832,30 @@ <classname>AminoAcid</classname> objects, and the output of the script confirms that: <informalexample> - <programlisting> + <screen> +<![CDATA[ ** Database of AminoAcid objects: Array ( - [0] => aminoacid Object + [0] => aminoacid Object ( - [name] => Alanine - [symbol] => ala - [code] => A - [type] => hydrophobic + [name] => Alanine + [symbol] => ala + [code] => A + [type] => hydrophobic ) - [1] => aminoacid Object + [1] => aminoacid Object ( - [name] => Lysine - [symbol] => lys - [code] => K - [type] => charged + [name] => Lysine + [symbol] => lys + [code] => K + [type] => charged ) ) - </programlisting> +]]> + </screen> </informalexample> </para> </refsect1> Index: phpdoc/en/functions/xslt.xml diff -u phpdoc/en/functions/xslt.xml:1.24 phpdoc/en/functions/xslt.xml:1.25 --- phpdoc/en/functions/xslt.xml:1.24 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/xslt.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.24 $ --> +<!-- $Revision: 1.25 $ --> <reference id="ref.xslt"> <title>XSLT functions</title> <titleabbrev>XSLT</titleabbrev> @@ -262,7 +262,8 @@ Transforming output through an XSLT stylesheet, using the DOM-XML functions for xml generation </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $xsl_file = "article.xsl"; xslt_output_begintransform($xsl_file); @@ -279,6 +280,7 @@ echo $doc->dumpmem(); xslt_output_endtransform(); +]]> </programlisting> </example> </para> @@ -339,48 +341,49 @@ <example> <title>Using the <function>xslt_process</function> to transform three strings</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php -$xslData = '<xsl:stylesheet +$xslData = '<xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -<xsl:template match="article"> - <table border="1" cellpadding="2" cellspacing="1"> - <tr> - <td width="20%"> +<xsl:template match="article"> + <table border="1" cellpadding="2" cellspacing="1"> + <tr> + <td width="20%"> &#160; - </td> - <td width="80%"> - <h2><xsl:value-of select="title"/></h2> - <h3><xsl:value-of select="author"/></h3> - <br/> + </td> + <td width="80%"> + <h2><xsl:value-of select="title"/></h2> + <h3><xsl:value-of select="author"/></h3> + <br/> - <xsl:copy-of select="p"/> - </td> - </tr> - </table> -</xsl:template> - -</xsl:stylesheet>'; - -$xmlData = '<?xml version="1.0"?> -<article> - <title>Learning German</title> - <author>Sterling Hughes</author> - <p> + <xsl:copy-of select="p"/> + </td> + </tr> + </table> +</xsl:template> + +</xsl:stylesheet>'; + +$xmlData = '<?xml version="1.0"?> +<article> + <title>Learning German</title> + <author>Sterling Hughes</author> + <p> Essential phrases: - <br/> - K&#246;nnen Sie mir sagen, wo die Toilette ist?<br/> - Ein grosses Bier, bitte!<br/> - Noch eins, bitte.<br/> - </p> -</article>'; + <br/> + K#246;nnen Sie mir sagen, wo die Toilette ist?<br/> + Ein grosses Bier, bitte!<br/> + Noch eins, bitte.<br/> + </p> +</article>'; if (xslt_process($xslData, $xmlData, $result)) { echo "Here is the brilliant in-depth article on learning"; echo " German: "; - echo "<br>\n<br>"; + echo "<br>\n<br>"; echo $result; } else { echo "There was an error that occurred in the XSL transformation...\n"; @@ -389,6 +392,7 @@ exit; } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/yaz.xml diff -u phpdoc/en/functions/yaz.xml:1.21 phpdoc/en/functions/yaz.xml:1.22 --- phpdoc/en/functions/yaz.xml:1.21 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/yaz.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.21 $ --> +<!-- $Revision: 1.22 $ --> <reference id="ref.yaz"> <title>YAZ functions</title> <titleabbrev>YAZ</titleabbrev> @@ -39,7 +39,8 @@ </para> <para> <informalexample> - <programlisting> + <programlisting role="shell"> +<![CDATA[ gunzip -c yaz-1.6.tar.gz|tar xf - gunzip -c php-4.0.X.tar.gz|tar xf - cd yaz-1.6 @@ -50,6 +51,7 @@ ./configure --with-yaz=/usr/bin make make install +]]> </programlisting> </informalexample> </para> @@ -71,33 +73,34 @@ host. </simpara> <programlisting role="php"> +<![CDATA[ $num_hosts = count ($host); if (empty($term) || count($host) == 0) { - echo '<form method="get"> - <input type="checkbox" - name="host[]" value="bagel.indexdata.dk/gils"> + echo '<form method="get"> + <input type="checkbox" + name="host[]" value="bagel.indexdata.dk/gils"> GILS test - <input type="checkbox" - name="host[]" value="localhost:9999/Default"> + <input type="checkbox" + name="host[]" value="localhost:9999/Default"> local test - <input type="checkbox" checked="1" - name="host[]" value="z3950.bell-labs.com/books"> + <input type="checkbox" checked="1" + name="host[]" value="z3950.bell-labs.com/books"> BELL Labs Library - <br> + <br> RPN Query: - <input type="text" size="30" name="term"> - <input type="submit" name="action" value="Search"> + <input type="text" size="30" name="term"> + <input type="submit" name="action" value="Search"> '; } else { - echo 'You searced for ' . htmlspecialchars($term) . '<br>'; - for ($i = 0; $i < $num_hosts; $i++) { + echo 'You searced for ' . htmlspecialchars($term) . '<br>'; + for ($i = 0; $i < $num_hosts; $i++) { $id[] = yaz_connect($host[$i]); yaz_syntax($id[$i],"sutrs"); yaz_search($id[$i],"rpn",$term); } yaz_wait(); - for ($i = 0; $i < $num_hosts; $i++) { - echo '<hr>' . $host[$i] . ":"; + for ($i = 0; $i < $num_hosts; $i++) { + echo '<hr>' . $host[$i] . ":"; $error = yaz_error($id[$i]); if (!empty($error)) { echo "Error: $error"; @@ -105,17 +108,18 @@ $hits = yaz_hits($id[$i]); echo "Result Count $hits"; } - echo '<dl>'; - for ($p = 1; $p <= 10; $p++) { + echo '<dl>'; + for ($p = 1; $p <= 10; $p++) { $rec = yaz_record($id[$i],$p,"string"); if (empty($rec)) continue; - echo "<dt><b>$p</b></dt><dd>"; - echo ereg_replace("\n", "<br>\n",$rec); - echo "</dd>"; + echo "<dt><b>$p</b></dt><dd>"; + echo ereg_replace("\n", "<br>\n",$rec); + echo "</dd>"; } - echo '</dl>'; + echo '</dl>'; } } +]]> </programlisting> </example> </para> @@ -650,29 +654,31 @@ <example> <title>PHP function that scans titles</title> <programlisting> +<![CDATA[ function scan_titles($id, $starterm) { yaz_scan($id,"rpn", "@attr 1=4 " . $starterm); yaz_wait(); $errno = yaz_errno($id); if ($errno == 0) { - $ar = yaz_scan_result($id,&$options); + $ar = yaz_scan_result($id,&$options); echo 'Scan ok; '; - $ar = yaz_scan_result($id, &$options); + $ar = yaz_scan_result($id, &$options); while(list($key,$val)=each($options)) { echo "$key = $val "; } - echo '<br><table><tr><td>'; + echo '<br><table><tr><td>'; while(list($key,list($k, $term, $tcount))=each($ar)) { if (empty($k)) continue; - echo "<tr><td>$term</td><td>"; + echo "<tr><td>$term</td><td>"; echo $tcount; - echo "</td></tr>"; + echo "</td></tr>"; } - echo '</table>'; + echo '</table>'; } else { - echo "Scan failed. Error: " . yaz_error($id) . "<br>"; + echo "Scan failed. Error: " . yaz_error($id) . "<br>"; } } +]]> </programlisting> </example> </para> @@ -748,10 +754,12 @@ target ID. </simpara> <programlisting> +<![CDATA[ $field["ti"] = "1=4"; $field["au"] = "1=1"; $field["isbn"] = "1=7"; yaz_ccl_conf($id,$field); +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/zip.xml diff -u phpdoc/en/functions/zip.xml:1.14 phpdoc/en/functions/zip.xml:1.15 --- phpdoc/en/functions/zip.xml:1.14 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/zip.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.14 $ --> +<!-- $Revision: 1.15 $ --> <reference id="ref.zip"> <title>Zip File Functions (Read Only Access)</title> <titleabbrev>Zip</titleabbrev> @@ -41,7 +41,8 @@ <example> <title>Zip Usage Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $zip = zip_open("/tmp/test2.zip"); @@ -68,7 +69,8 @@ } -?> +?> +]]> </programlisting> </example> </sect1> Index: phpdoc/en/functions/zlib.xml diff -u phpdoc/en/functions/zlib.xml:1.19 phpdoc/en/functions/zlib.xml:1.20 --- phpdoc/en/functions/zlib.xml:1.19 Sat Nov 10 16:49:42 2001 +++ phpdoc/en/functions/zlib.xml Wed Nov 21 18:05:19 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <reference id="ref.zlib"> <title>Zlib Compression Functions</title> <titleabbrev>Zlib</titleabbrev> @@ -40,11 +40,12 @@ </para> <example> <title>Small Zlib Example</title> -<programlisting role="php"> -<?php + <programlisting role="php"> +<![CDATA[ +<?php $filename = tempnam ('/tmp', 'zlibtest').'.gz'; -print "<html>\n<head></head>\n<body>\n<pre>\n"; +print "<html>\n<head></head>\n<body>\n<pre>\n"; $s = "Only a test, test, test, test, test, test, test, test!\n"; // open file for writing with maximum compression @@ -72,9 +73,10 @@ echo "Error with zlib functions!"; } unlink($filename); -print "</pre>\n</h1></body>\n</html>\n"; +print "</pre>\n</h1></body>\n</html>\n"; ?> +]]> </programlisting> </example> </sect1> @@ -314,7 +316,9 @@ <example> <title><function>gzopen</function> Example</title> <programlisting role="php"> +<![CDATA[ $fp = gzopen ("/tmp/file.gz", "r"); +]]> </programlisting> </example> </para> @@ -405,11 +409,13 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ // get contents of a gz-file into a string $filename = "/usr/local/something.txt.gz"; $zd = gzopen ($filename, "r"); $contents = gzread ($zd, 10000); gzclose ($zd); +]]> </programlisting> </informalexample> </para> @@ -787,13 +793,15 @@ <example> <title>Creating a gzip file</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $data = implode("", "bigfile.txt"); $gzdata = gzencode($data, 9); $fp = fopen("bigfile.txt.gz", "w"); fwrite($fp, $gzdata); fclose($fp); -?> +?> +]]> </programlisting> </example> </para>