From 65a93a86a8843495b2aa0b4ebd1f94684d31a15f Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Wed, 21 Nov 2001 23:05:19 +0000 Subject: [PATCH] last bunch of /CDATA changes git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@62977 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/oracle.xml | 16 ++- functions/outcontrol.xml | 54 ++++---- functions/ovrimos.xml | 56 +++++--- functions/pcntl.xml | 18 ++- functions/pcre.xml | 121 ++++++++++++------ functions/pdf.xml | 34 +++-- functions/pfpro.xml | 12 +- functions/pgsql.xml | 50 +++++--- functions/printer.xml | 44 ++++++- functions/pspell.xml | 34 ++++- functions/readline.xml | 4 +- functions/recode.xml | 10 +- functions/regex.xml | 46 +++++-- functions/satellite.xml | 34 +++-- functions/sesam.xml | 199 +++++++++++++++++------------ functions/session.xml | 51 +++++--- functions/shmop.xml | 44 ++++--- functions/snmp.xml | 28 +++- functions/sockets.xml | 30 +++-- functions/strings.xml | 200 ++++++++++++++++++++++------- functions/swf.xml | 20 ++- functions/uodbc.xml | 14 +- functions/url.xml | 24 +++- functions/var.xml | 68 ++++++++-- functions/wddx.xml | 53 +++++--- functions/xml.xml | 268 +++++++++++++++++++++------------------ functions/xslt.xml | 68 +++++----- functions/yaz.xml | 66 +++++----- functions/zip.xml | 8 +- functions/zlib.xml | 22 +++- 30 files changed, 1117 insertions(+), 579 deletions(-) diff --git a/functions/oracle.xml b/functions/oracle.xml index 35b6d19f8f..0f66994312 100644 --- a/functions/oracle.xml +++ b/functions/oracle.xml @@ -1,5 +1,5 @@ - + Oracle functions Oracle @@ -43,15 +43,17 @@ values if available. -<?php +Out: $output<BR>In: $input"; +echo "Result: $result
Out: $output
In: $input"; ?> +]]>
@@ -414,12 +416,14 @@ remove the unique restriction or do not insert the key Oracle fetch into array -<?php + +]]> Note that you need to fetch the array by reference. @@ -511,7 +515,7 @@ echo $results[1]; $conn = Ora_Logon("user@TNSNAME", "pass"); - +
diff --git a/functions/outcontrol.xml b/functions/outcontrol.xml index 695807926b..6f497c8fe4 100644 --- a/functions/outcontrol.xml +++ b/functions/outcontrol.xml @@ -1,5 +1,5 @@ - + Output Control Functions Output Control @@ -19,7 +19,8 @@ Output Control example -<?php + +]]> @@ -154,7 +156,8 @@ ob_end_flush(); User defined callback function example -<?php + -<html> -<body> -<p>It's like comparing apples to oranges. -</body> -</html> + + +

It's like comparing apples to oranges. + + -<?php + +]]> Would produce: -<html> -<body> -<p>It's like comparing oranges to oranges. -</body> -</html> + + +

It's like comparing oranges to oranges. + + +]]> @@ -284,16 +290,18 @@ ob_end_flush(); <function>ob_gzhandler</function> Example -<?php + -<html> -<body> -<p>This should be a compressed page. -</html> -</body> + + +

This should be a compressed page. + + +]]> diff --git a/functions/ovrimos.xml b/functions/ovrimos.xml index d52b376b5f..a1564cc760 100644 --- a/functions/ovrimos.xml +++ b/functions/ovrimos.xml @@ -1,5 +1,5 @@ - + Ovrimos SQL functions OvrimosSQL @@ -22,7 +22,8 @@ Connect to Ovrimos SQL Server and select from a system table -<?php + +]]> This will just connect to SQL Server. @@ -72,7 +74,8 @@ if ($conn != 0) { <function>ovrimos_connect</function> Example -<?php + +]]> The above example will connect to the database and print out the @@ -172,7 +176,8 @@ if ($conn != 0) { Connect to Ovrimos SQL Server and prepare a statement -<?php + +]]> This will connect to Ovrimos SQL Server, prepare a statement and @@ -326,17 +332,18 @@ if ($conn!=0) { A fetch into example -<?php + +]]> This example will fetch a row. @@ -389,7 +397,8 @@ if ($conn!=0) { A fetch row example -<?php + +]]> This will fetch a row and print the result. @@ -478,7 +488,8 @@ if ($conn != 0) { Prepare a statement, execute, and view the result -<?php + +]]> This will execute an SQL statement and print the result in an @@ -508,7 +520,8 @@ if ($conn != 0) { Ovrimos_result_all with meta-information -<?php + +]]> @@ -537,7 +551,8 @@ if ($conn != 0) { ovrimos_result_all example -<?php + +]]> diff --git a/functions/pcntl.xml b/functions/pcntl.xml index 52e4792afb..a41ca83e45 100644 --- a/functions/pcntl.xml +++ b/functions/pcntl.xml @@ -1,5 +1,5 @@ - + Process Control Functions PCNTL @@ -114,7 +114,8 @@ Process Control Example -<?php + +]]> @@ -195,7 +197,8 @@ function sig_handler($signo) { <function>pcntl_fork</function> Example -<?php + +]]> @@ -246,7 +250,8 @@ if ($pid == -1) { <function>pcntl_signal</function> Example -<?php + +]]> diff --git a/functions/pcre.xml b/functions/pcre.xml index 4a3c2d07bf..d6f9849e5a 100644 --- a/functions/pcre.xml +++ b/functions/pcre.xml @@ -1,5 +1,5 @@ - + Regular Expression Functions (Perl-Compatible) PCRE @@ -23,7 +23,7 @@ Examples of valid patterns - /<\/\w+>/ + /<\/\w+>/ |(\d{3})-\d+|Sm /^(?i)php[34]/ {^\s+(\s+)?$} @@ -102,17 +102,20 @@ Find the string of text "php" + find the word "web" + Getting the domain name out of a URL + - + This example will produce: - + + +]]> + + + See also preg_match_all, preg_replace, and preg_split. @@ -190,22 +200,26 @@ domain name is: php.net the first parenthesized subpattern, and so on. -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +]+>(.*)]+>|U", + "example:

this is a test
", $out, PREG_PATTERN_ORDER); print $out[0][0].", ".$out[0][1]."\n"; print $out[1][0].", ".$out[1][1]."\n" -
- - This example will produce: - - -<b>example: </b>, <div align=left>this is a test</div> +]]> + + + This example will produce: + +example: ,
this is a test
example: , this is a test - -
- So, $out[0] contains array of strings that matched full pattern, - and $out[1] contains array of strings enclosed by tags. +]]> + + So, $out[0] contains array of strings that matched full pattern, + and $out[1] contains array of strings enclosed by tags. + + @@ -218,18 +232,22 @@ example: , this is a test and so on. -preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", - "<b>example: </b><div align=left>this is a test</div>", +]+>(.*)]+>|U", + "example:
this is a test
", $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"; +]]>
This example will produce: -<b>example: </b>, example: -<div align=left>this is a test</div>, this is a test +example: , example: +
this is a test
, this is a test +]]>
In this case, $matches[0] is the first set of matches, and @@ -252,8 +270,10 @@ print $out[1][0].", ".$out[1][1]."\n" Getting all phone numbers out of some text. + @@ -261,33 +281,37 @@ preg_match_all ("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x", Find matching HTML tags (greedy) +bold textclick me -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"; } +]]> This example will produce: -matched: <b>bold text</b> -part 1: <b> +bold text +part 1: part 2: bold text -part 3: </b> +part 3: -matched: <a href=howdy.html>click me</a> -part 1: <a href=howdy.html> +matched: click me +part 1: part 2: click me -part 3: </a> +part 3: +]]> @@ -378,37 +402,44 @@ part 3: </a> Replacing several values + This example will produce: + Using /e modifier -preg_replace ("/(<\/?)(\w+)([^>]*>)/e", +]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); +]]> -This would capitalize all HTML tags in the input text. + This would capitalize all HTML tags in the input text. Convert HTML to text +]*?>.*?'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 @@ $replace = array ("", "\\1", "\"", "&", - "<", - ">", + "<", + ">", " ", chr(161), chr(162), @@ -436,6 +467,7 @@ $replace = array ("", "chr(\\1)"); $text = preg_replace ($search, $replace, $document); +]]> @@ -552,9 +584,11 @@ $text = preg_replace ($search, $replace, $document); <function>preg_split</function> example : Get the parts of a search string. + @@ -562,9 +596,11 @@ $keywords = preg_split ("/[\s,]+/", "hypertext language, programming"); Splitting a string into component characters. + @@ -611,21 +647,23 @@ print_r($chars); used delimiter. The special regular expression characters are: - . \\ + * ? [ ^ ] $ ( ) { } = ! < > | : + . \\ + * ? [ ^ ] $ ( ) { } = ! < > | : + Italicizing a word within some text - +".$word."", $textbody); +]]> @@ -673,9 +712,11 @@ $textbody = preg_replace ("/".preg_quote($word)."/", <function>preg_grep</function> example + diff --git a/functions/pdf.xml b/functions/pdf.xml index 26bc6e92d5..6f0571b408 100644 --- a/functions/pdf.xml +++ b/functions/pdf.xml @@ -1,5 +1,5 @@ - + PDF functions PDF @@ -256,7 +256,8 @@ Creating a PDF document with PDFlib -<?php +finished</A>"; +echo "finished"; ?> +]]> The script getpdf.php just returns the pdf document. -<?php + +]]> @@ -305,7 +309,8 @@ readfile($filename); pdfclock example from PDFlib distribution -<?php + 0) { /* 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 @@ while($pagecount-- > 0) { /* 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 @@ print $buf; pdf_delete($pdf); ?> +]]> @@ -1187,14 +1193,16 @@ pdf_delete($pdf); <function>pdf_findfont</function> example -<php + +]]> @@ -1572,7 +1580,8 @@ if ($font) { Creating a PDF document in memory -<?php + +]]> @@ -1712,7 +1722,8 @@ echo $data; Including a memory image -<?php + +]]> diff --git a/functions/pfpro.xml b/functions/pfpro.xml index 1050acb5c9..3c77e14bec 100644 --- a/functions/pfpro.xml +++ b/functions/pfpro.xml @@ -1,5 +1,5 @@ - + Verisign Payflow Pro functions Verisign Payflow Pro @@ -180,7 +180,8 @@ Payflow Pro example -<?php + +]]> @@ -277,11 +279,12 @@ pfpro_cleanup(); Payflow Pro raw example -<?php + +]]> diff --git a/functions/pgsql.xml b/functions/pgsql.xml index 2dee284b99..e721832775 100644 --- a/functions/pgsql.xml +++ b/functions/pgsql.xml @@ -1,5 +1,5 @@ - + PostgreSQL functions PostgreSQL @@ -89,7 +89,8 @@ Using Large Objects -<?php + +]]> @@ -155,11 +157,13 @@ <function>pg_cmdtuples</function> -<?php + +]]> @@ -211,7 +215,8 @@ echo $cmdtuples . " <- cmdtuples affected."; Using pg_connect arguments -<?php + +]]> The arguments available include host, @@ -409,7 +415,8 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa PostgreSQL fetch array -<?php + +]]> @@ -483,11 +491,12 @@ echo $arr["author"] . " <- array\n"; Postgres fetch object -<?php + - <H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php +

Failed connecting to postgres database

autor." ("; echo $data->jahr ."): "; - echo $data->titel."<BR>"; + echo $data->titel."
"; $row++; endwhile; ?> -<PRE><?php +

-</PRE> <?php
+
+]]>
@@ -557,7 +567,8 @@ pg_close ($db_conn); Postgres fetch row -<?php +"; + echo "
"; } ?> +]]>
@@ -1203,7 +1215,8 @@ for ($i=0; $i<$num; $i++) { High-speed insertion of data into a table -<?php + +]]> diff --git a/functions/printer.xml b/functions/printer.xml index 1bebb65b8b..d53cfbeb67 100644 --- a/functions/printer.xml +++ b/functions/printer.xml @@ -1,5 +1,5 @@ - + Printer functions Printer @@ -41,8 +41,10 @@ <function>printer_open</function> example + @@ -71,9 +73,11 @@ $handle = printer_open(); <function>printer_abort</function> example + @@ -103,8 +107,10 @@ printer_close($handle); <function>printer_close</function> example + @@ -135,9 +141,11 @@ printer_close($handle); <function>printer_write</function> example + @@ -219,8 +227,10 @@ printer_close($handle); <function>printer_list</function> example + @@ -448,10 +458,12 @@ var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) ); <function>printer_set_option</function> example + @@ -495,9 +507,11 @@ printer_close($handle); <function>printer_get_option</function> example + @@ -525,6 +539,7 @@ printer_close($handle); <function>printer_create_dc</function> example + @@ -599,6 +615,7 @@ printer_close($handle); <function>printer_start_doc</function> example + @@ -803,6 +821,7 @@ printer_close($handle); printer_select_pen example +
@@ -951,6 +971,7 @@ printer_close($handle); printer_select_brush example + @@ -1128,6 +1150,7 @@ printer_close($handle); printer_select_font example + @@ -1170,9 +1194,11 @@ printer_close($handle); printer_logical_fontheight example + @@ -1226,6 +1252,7 @@ printer_close($handle); <function>printer_draw_roundrect</function> example + @@ -1290,6 +1318,7 @@ printer_close($handle); printer_draw_rectangle example + @@ -1352,6 +1382,7 @@ printer_close($handle); printer_draw_elipse example + @@ -1401,6 +1433,7 @@ printer_close($handle); <function>printer_draw_text</function> example + @@ -1445,6 +1479,7 @@ printer_close($handle); <function>printer_draw_line</function> example + @@ -1526,6 +1562,7 @@ printer_close($handle); <function>printer_draw_chord</function> example + @@ -1609,6 +1647,7 @@ printer_close($handle); <function>printer_draw_chord</function> example + @@ -1661,6 +1701,7 @@ printer_close($handle); <function>printer_draw_bmp</function> example + diff --git a/functions/pspell.xml b/functions/pspell.xml index ebe67b97f1..2388d394d9 100644 --- a/functions/pspell.xml +++ b/functions/pspell.xml @@ -1,5 +1,5 @@ - + @@ -46,12 +46,14 @@ <function>pspell_add_to_personal</function> + @@ -103,6 +105,7 @@ pspell_save_wordlist ($pspell_link); <function>pspell_check</function> + @@ -138,6 +142,7 @@ if (pspell_check ($pspell_link, "testt")) { <function>pspell_add_to_personal</function> + @@ -242,10 +248,12 @@ pspell_save_wordlist ($pspell_link); //"Vlad" will not be saved <function>pspell_config_create</function> + @@ -276,10 +284,12 @@ $pspell_link = pspell_new_personal ($pspell_config, "en"); <function>pspell_config_ignore</function> + @@ -333,10 +343,12 @@ pspell_check($pspell_link, "abcd"); //will not result in an error <function>pspell_config_mode</function> + @@ -372,10 +384,12 @@ pspell_check($pspell_link, "thecat"); <function>pspell_config_personal</function> + @@ -412,11 +426,13 @@ pspell_check ($pspell_link, "thecat"); <function>pspell_config_repl</function> + @@ -451,10 +467,12 @@ pspell_check ($pspell_link, "thecat"); <function>pspell_config_runtogether</function> + @@ -597,8 +615,10 @@ pspell_check ($pspell_link, "thecat"); <function>pspell_new</function> + @@ -636,10 +656,12 @@ $pspell_link = pspell_new ("en", "", "", "", <function>pspell_new_config</function> + @@ -767,8 +789,10 @@ $pspell_link = pspell_new_config ($pspell_config); <function>pspell_new_personal</function> + @@ -801,12 +825,14 @@ $pspell_link = pspell_new_personal ("/var/dictionaries/custom.pws", <function>pspell_add_to_personal</function> + @@ -845,6 +871,7 @@ pspell_save_wordlist ($pspell_link); <function>pspell_store_replacement</function> + @@ -880,15 +908,17 @@ pspell_save_wordlist ($pspell_link); <function>pspell_suggest</function> +"; + echo "Possible spelling: $suggestion
"; } } +]]>
diff --git a/functions/readline.xml b/functions/readline.xml index d086b5bbf2..fefe120bf1 100644 --- a/functions/readline.xml +++ b/functions/readline.xml @@ -1,5 +1,5 @@ - + GNU Readline Readline @@ -47,6 +47,7 @@ <function>readline</function> + diff --git a/functions/recode.xml b/functions/recode.xml index 07afad7cf5..27168d94c1 100644 --- a/functions/recode.xml +++ b/functions/recode.xml @@ -1,5 +1,5 @@ - + GNU Recode functions Recode @@ -48,7 +48,9 @@ Basic <function>recode_string</function> example: -print recode_string ("us..flat", "The following character has a diacritical mark: &aacute;"); + @@ -110,9 +112,11 @@ print recode_string ("us..flat", "The following character has a d Basic <function>recode_file</function> example + diff --git a/functions/regex.xml b/functions/regex.xml index 9d2f1b0cfe..a4cf604c2a 100644 --- a/functions/regex.xml +++ b/functions/regex.xml @@ -1,5 +1,5 @@ - + Regular Expression Functions (POSIX Extended) Regexps @@ -55,16 +55,17 @@ Regular Expression Examples -ereg ("abc", $string); -/* Returns true if "abc" +", $string); +/* Put a
tag at the beginning of $string. */ -$string = ereg_replace ("$", "<br />", $string); -/* Put a <br /> tag at the end of $string. */ +$string = ereg_replace ("$", "
", $string); +/* Put a
; tag at the end of $string. */ $string = ereg_replace ("\n", "", $string); /* Get rid of any newline characters in $string. */ +]]>
@@ -149,11 +151,13 @@ $string = ereg_replace ("\n", "", $string); <function>ereg</function> Example + @@ -219,10 +223,12 @@ if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) { <function>ereg_replace</function> Example + @@ -235,7 +241,8 @@ echo ereg_replace ("(( )is)", "\\2was", $string); <function>ereg_replace</function> Example -<?php + +]]> @@ -255,8 +263,10 @@ echo $string; /* Output: 'This string has 4 words.' */ Replace URLs with links -$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", - "<a href=\"\\0\">\\0</a>", $text); +[:space:]]+[[:alnum:]/]", + "\\0", $text); +]]> @@ -291,9 +301,11 @@ $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", <function>eregi</function> example + @@ -372,7 +384,9 @@ if (eregi("z", $string)) { <function>split</function> Example + @@ -392,9 +406,11 @@ list($user,$pass,$uid,$gid,$extra)= split (":", $passwd_line, 5); <function>split</function> Example +\n"; +]]> @@ -498,7 +514,9 @@ echo "Month: $month; Day: $day; Year: $year<br>\n"; <function>sql_regcase</function> Example + prints [Ff][Oo][Oo] [Bb][Aa][Rr]. diff --git a/functions/satellite.xml b/functions/satellite.xml index 1bc1d170a4..87f33d1748 100644 --- a/functions/satellite.xml +++ b/functions/satellite.xml @@ -1,5 +1,5 @@ - + @@ -38,13 +38,15 @@ Sample IDL file - + + @@ -52,7 +54,8 @@ interface MyInterface { PHP code for accessing MyInterface -<?php +SetInfo ("A 2GooD object"); @@ -63,6 +66,7 @@ $obj->value = 42; echo $obj->value; ?> +]]> @@ -93,10 +97,12 @@ echo $obj->value; Sample IDL file - + + @@ -104,13 +110,15 @@ enum MyEnum { PHP code for accessing MyEnum -<?php +a; /* write 0 */ echo $enum->c; /* write 2 */ echo $enum->e; /* write 4 */ ?> +]]> @@ -141,7 +149,8 @@ echo $enum->e; /* write 4 */ Sample IDL file - + + @@ -158,7 +168,8 @@ interface SomeInterface { PHP code for accessing MyStruct -<?php +GetValues(); echo $values->shortvalue; echo $values->stringvalue; ?> +]]> @@ -202,7 +214,8 @@ echo $values->stringvalue; Sample IDL file - + + @@ -218,7 +232,8 @@ interface AnotherInterface { PHP code for handling CORBA exceptions -<?php +AskWhy(); @@ -230,6 +245,7 @@ if (satellite_caught_exception()) { } } ?> +]]> diff --git a/functions/sesam.xml b/functions/sesam.xml index c76649284f..2d7dcea45a 100644 --- a/functions/sesam.xml +++ b/functions/sesam.xml @@ -1,5 +1,5 @@ - + SESAM database functions SESAM @@ -63,7 +63,9 @@ Example: + @@ -78,16 +80,20 @@ php3_sesam_oml $.SYSLNK.SESAM-SQL.030 Example: + It will usually contain a configuration like (see SESAM reference manual): + @@ -104,7 +110,9 @@ NOTYPE Example: + @@ -454,18 +462,22 @@ php3_sesam_messagecatalog $.SYSMES.SESAM-SQL.030 Creating a "multiple field" column + and can be filled in using: Filling a "multiple field" column +) +]]> Note that (like in this case) leading empty sub-fields are @@ -540,10 +552,12 @@ INSERT INTO multi_field_test (pkey, multi(2..3) ) Connect to a SESAM database -<?php + +]]> @@ -590,10 +604,12 @@ if (!sesam_connect ("mycatalog", "myschema", "otto") Closing a SESAM connection + @@ -709,10 +725,12 @@ if (sesam_connect ("mycatalog", "myschema", "otto")) { Setting SESAM transaction parameters -<?php + +]]> @@ -756,14 +774,16 @@ sesam_settransaction (SESAM_TXISOL_REPEATABLE_READ, Committing an update to the SESAM database -<?php +)")) die("insert failed"); if (!sesam_commit()) die("commit failed"); } -?> +?> +]]> @@ -805,15 +825,17 @@ if (sesam_connect ("mycatalog", "myschema", "otto")) { Discarding an update to the SESAM database -<?php +)") + && sesam_execimm ("INSERT INTO othertable VALUES (*, 'Another Test', 1)")) sesam_commit(); else sesam_rollback(); } -?> +?> +]]> @@ -863,12 +885,14 @@ if (sesam_connect ("mycatalog", "myschema", "otto")) { + See also: sesam_query and @@ -937,7 +961,8 @@ print ("sqlstate = ".$err["sqlstate"]."\n". Show all rows of the "phone" table as a html table -<?php +\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 " Result:\n"; + echo " \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 " ".$colattr["name"]. + "(1..".$colattr["count"].")\n"; $col += $colattr["count"] - 1; } else - echo " <TH>" . $colattr["name"] . "</TH>\n"; + echo " " . $colattr["name"] . "\n"; } - echo " </TR>\n"; + echo " \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 " \n"; + for ($col = 0; $col < $ok["cols"]; ++$col) { if (isset($ok[$col][$row])) - echo " <TD>" . $ok[$col][$row] . "</TD>\n"; + echo " " . $ok[$col][$row] . "\n"; } else { - echo " <TD>-empty-</TD>\n"; + echo " -empty-\n"; } } - echo " </TR>\n"; + echo " \n"; } } while ($ok["truncated"]) { // while there may be more data - echo "</TABLE>\n"; + echo "\n"; } // free result id sesam_free_result($result); -?> +?> +]]> @@ -1139,7 +1165,8 @@ sesam_free_result($result); Displaying SESAM error messages with error position -<?php +\n"; + echo "ERROR: ". + htmlspecialchars($err["errmsg"])."\n"; + if ($err["errcol"] >= 0) { + echo "
\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 @@ function PrintReturncode ($exec_str) {
                     $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 "\\\n";
+                print "".htmlspecialchars($line)."";
+                for ($col=0; $col < $err["errcol"]; ++$col)
                     echo (substr ($line, $col, 1) == "\t") ? "\t" : ".";
-                echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n";
+                echo "/\n";
             }
         }
-        echo "</PRE></TD></TR>\n";
+        echo "
\n"; } - echo "<TR>\n"; - echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; + echo "\n"; + echo " sqlstate=" . $err["sqlstate"] . "\n"; if ($err["errlin"] != -1) - echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; + echo " errlin=" . $err["errlin"] . "\n"; if ($err["errcol"] != -1) - echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; + echo " errcol=" . $err["errcol"] . "\n"; if ($err["rowcount"] != 0) - echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; - echo "</TR>\n"; - echo "</TABLE>\n"; + echo " rowcount=" . $err["rowcount"] . "\n"; + echo "\n"; + echo "\n"; } if (!sesam_connect ("mycatalog", "phoneno", "otto")) @@ -1202,7 +1229,8 @@ $stmt = "SELECT * FROM phone\n". " ORDER BY FIRSTNAME"; if (!($result = sesam_query ($stmt))) PrintReturncode ($stmt); -?> +?> +]]>
@@ -1350,12 +1378,14 @@ if (!($result = sesam_query ($stmt))) + @@ -1380,8 +1410,10 @@ print sesam_affected_rows ($result). +\n", sesam_errormsg()); +]]> @@ -1729,28 +1761,30 @@ if (!sesam_execimm ($stmt)) SESAM fetch rows -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +\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 " \n"; + for ($col = 0; $col < $row["count"]; ++$col) { + print " ".htmlspecialchars ($row[$col])."\n"; } - print " </TR>\n"; + print " \n"; // use implied SESAM_SEEK_PRIOR $row = sesam_fetch_row ($result); } -print "</TABLE>\n"; +print "\n"; sesam_free_result ($result); -?> +?> +]]> @@ -1816,8 +1850,11 @@ sesam_free_result ($result); call sesam_fetch_row or make an alias for the column. - -SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2 + + + @@ -1831,7 +1868,9 @@ SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2 declared as: + the associative indices used for the individual "multiple field" @@ -1848,25 +1887,27 @@ CREATE TABLE ... ( ... MULTI(3) INT ) SESAM fetch array -<?php -$result = sesam_query ("SELECT * FROM phone\n". - " WHERE LASTNAME='".strtoupper($name)."'\n". - " ORDER BY FIRSTNAME", 1); +\n"; +while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { + print " \n"; + print " ".htmlspecialchars ($row["firstname"])."\n"; + print " ".htmlspecialchars ($row["lastname"])."\n"; + print " ".htmlspecialchars ($row["phoneno"])."\n"; + print " \n"; } -print "</TABLE>\n"; +print "\n"; sesam_free_result ($result); -?> +?> +]]> diff --git a/functions/session.xml b/functions/session.xml index 6a8e127d55..4ca3c0a1cc 100644 --- a/functions/session.xml +++ b/functions/session.xml @@ -1,5 +1,5 @@ - + Session handling functions Sessions @@ -69,10 +69,12 @@ enabled -<?php + +]]> @@ -89,10 +91,12 @@ $HTTP_SESSION_VARS["count"]++; enabled -<?php + +]]> @@ -142,19 +146,21 @@ $count++; Counting the number of hits of a single user -<?php + Hello visitor, you have seen this page <?php echo $count; ?> times.<p> -<php? -# the <?=SID?> is necessary to preserve the session id + 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, click here +]]> @@ -421,14 +427,16 @@ To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> <function>session_name</function> examples -<?php +"; +?> +]]> @@ -846,8 +854,8 @@ echo "The previous session name was $previous_name<p>"; session_set_save_handler example -<?php - + +]]> @@ -964,15 +973,17 @@ session_start(); <function>session_cache_limiter</function> examples -<?php +"; +?> +]]> diff --git a/functions/shmop.xml b/functions/shmop.xml index a642e35329..3fb2a4366f 100755 --- a/functions/shmop.xml +++ b/functions/shmop.xml @@ -1,5 +1,5 @@ - + Shared Memory Functions shmop @@ -24,7 +24,8 @@ Shared Memory Operations Overview -<?php + +]]> @@ -114,9 +116,11 @@ shmop_close($shm_id); Create a new shared memory block -<?php + +]]> @@ -153,9 +157,11 @@ $shm_id = shmop_open(0x0fff, "c", 0644, 100); Reading shared memory block -<?php + +]]> @@ -194,9 +200,11 @@ $shm_data = shmop_read($shm_id, 0, 50); Writing to shared memory block -<?php + +]]> @@ -235,9 +243,11 @@ $shm_bytes_written = shmop_write($shm_id, $my_string, 0); Getting the size of the shared memory block -<?php + +]]> @@ -273,9 +283,11 @@ $shm_size = shmop_size($shm_id); Deleting shared memory block -<?php + +]]> @@ -310,9 +322,11 @@ shmop_delete($shm_id); Closing shared memory block -<?php + +]]> diff --git a/functions/snmp.xml b/functions/snmp.xml index 0e724de2e8..b05e6c3e83 100644 --- a/functions/snmp.xml +++ b/functions/snmp.xml @@ -1,5 +1,5 @@ - + SNMP functions SNMP @@ -16,8 +16,10 @@ #define line. It should look like this afterwards: - + + @@ -60,7 +62,9 @@ + @@ -139,7 +143,9 @@ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); + @@ -150,9 +156,11 @@ $a = snmpwalk("127.0.0.1", "public", ""); -for ($i=0; $i<count($a); $i++) { + @@ -204,7 +212,9 @@ for ($i=0; $i<count($a); $i++) { + @@ -215,9 +225,11 @@ $a = snmpwalkoid("127.0.0.1", "public", ""); +\n"; + echo "$i: $a[$i]
\n"; } +]]>
@@ -246,7 +258,9 @@ for (reset($a); $i = key($a); next($a)) { + @@ -297,12 +311,14 @@ $quickprint = snmp_get_quick_print(); +\n"; +echo "$a
\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
\n"; +]]>
diff --git a/functions/sockets.xml b/functions/sockets.xml index 52881cab56..e73fc17db3 100644 --- a/functions/sockets.xml +++ b/functions/sockets.xml @@ -1,5 +1,5 @@ - + Socket functions Sockets @@ -48,7 +48,8 @@ side, and echoed back to you. To disconnect, enter 'quit'. -<?php + +]]> @@ -110,10 +112,11 @@ close ($sock); and exits. -<?php +TCP/IP Connection</h2>\n"; +echo "

TCP/IP Connection

\n"; /* Get the port for the WWW service. */ $service_port = getservbyname ('www', 'tcp'); @@ -123,7 +126,7 @@ $address = gethostbyname ('www.php.net'); /* 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 @@ if ($socket < 0) { 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 @@ echo "Closing socket..."; close ($socket); echo "OK.\n\n"; ?> +]]>
@@ -546,7 +550,8 @@ echo "OK.\n\n"; <function>strerror</function> example -<?php + +]]> The expected output from the above example (assuming the script diff --git a/functions/strings.xml b/functions/strings.xml index dc0aeea438..8b62e7fbc3 100644 --- a/functions/strings.xml +++ b/functions/strings.xml @@ -1,5 +1,5 @@ - + String functions Strings @@ -54,7 +54,9 @@ <function>addcslashes</function> example + @@ -64,9 +66,11 @@ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); characters that you set as the start and end of the range. + Also, if the first character in a range has a lower ASCII value @@ -76,11 +80,13 @@ echo addcslashes('foo[]', 'A..z'); ASCII value for a character. + @@ -192,11 +198,13 @@ echo addcslashes("zoo['.']", 'z..A'); <function>chr</function> example + @@ -242,9 +250,11 @@ $str = sprintf("The string ends in escape: %c", 27); <function>chunk_split</function> example + This function is significantly faster than @@ -523,7 +533,8 @@ $new_string = chunk_split(base64_encode($data)); <function>echo</function> examples -<?php + +]]> @@ -562,7 +574,9 @@ echo $some_var ? 'true': 'false'; // changing the statement around can immediately follow the opening tag with an equals sign. -I have <?=$foo?> foo. + foo. +]]> @@ -617,8 +631,10 @@ I have <?=$foo?> foo. <function>explode</function> example + @@ -679,9 +695,11 @@ $pieces = explode(" ", $pizza); Translation Table Example + & Krämer"; +$str = "Hallo & & Krämer"; $encoded = strtr($str, $trans); +]]> The $encoded variable will now contain: "Hallo @@ -694,8 +712,10 @@ $encoded = strtr($str, $trans); the direction of the translation. + The content of $original would be: "Hallo & @@ -739,9 +759,11 @@ $original = strtr($str, $trans); Meta Tags Example -<meta name="author" content="name"> -<meta name="tags" content="php3 documentation"> -</head> <!-- parsing stops here --> + + + +]]> (pay attention to line endings - PHP uses a native function to @@ -947,7 +969,9 @@ $original = strtr($str, $trans); <function>htmlspecialchars</function> example -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +Test", ENT_QUOTES); +]]> @@ -989,7 +1013,9 @@ $new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); <function>implode</function> example + @@ -1334,11 +1360,12 @@ $colon_separated = implode(":", $array); <function>localeconv</function> example +\n"; echo "--------------------------------------------\n"; echo " Monetary information for current locale: \n"; echo "--------------------------------------------\n\n"; @@ -1357,7 +1384,8 @@ echo "n_cs_precedes: {$locale_info["n_cs_precedes"]}\n"; 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 "\n"; +]]> @@ -1596,9 +1624,11 @@ $clean = ltrim($binary,"\0x00..\0x1F"); <function>ord</function> example + @@ -1639,11 +1669,13 @@ if (ord($str) == 10) { Using <function>parse_str</function> -$str = "first=value&second[]=this+works&second[]=another"; + @@ -1890,12 +1922,14 @@ $clean = rtrim($binary,"\0x00..\0x1F"); <function>sscanf</function> Example + If optional parameters are passed, the function will return the @@ -1904,13 +1938,15 @@ echo "Item $serial was manufactured on: $year-".substr($month,0,3)."-$day\n"; <function>sscanf</function> - using optional parameters + + $first + $last +\n"; +]]> @@ -2062,12 +2098,14 @@ echo "<author id='$id'> Soundex Examples + @@ -2201,8 +2239,10 @@ soundex("Lukasiewicz") == soundex("Lissajous") == 'L222'; Argument swapping + This might output, "There are 5 monkeys in the tree". But @@ -2212,8 +2252,10 @@ printf($format,$num,$location); Argument swapping + We now have a problem. The order of the placeholders in the @@ -2224,8 +2266,10 @@ printf($format,$num,$location); Argument swapping + An added benefit here is that you can repeat the placeholders without @@ -2233,9 +2277,11 @@ printf($format,$num,$location); Argument swapping + @@ -2251,18 +2297,22 @@ printf($format, $num, $location); <function>sprintf</function>: zero-padded integers + <function>sprintf</function>: formatting currency + @@ -2333,11 +2383,13 @@ $formatted = sprintf("%01.2f", $money); <function>strcasecmp</function> example + @@ -2511,7 +2563,9 @@ if (!strcasecmp($var1, $var2)) { <function>strip_tags</function> example -$string = strip_tags($string, '<a><b><i><u>'); +'); +]]> @@ -2665,6 +2719,7 @@ $string = strip_tags($string, '<a><b><i><u>'); below: + The code above will generate the following output: - + + 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 ) - +]]> + For more information see: Martin Pool's Natural Order String Comparison @@ -2853,10 +2911,12 @@ Array <function>str_pad</function> example + @@ -2899,6 +2959,7 @@ print str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___" the difference: + @@ -2968,12 +3030,14 @@ if (is_string($pos) && !$pos) { <function>strrchr</function> example + @@ -3006,7 +3070,9 @@ $last = substr(strrchr($text, 10), 1 ); <function>str_repeat</function> example + @@ -3038,9 +3104,11 @@ echo str_repeat("-=", 10); Reversing a string with <function>strrev</function> -<php + +]]> @@ -3080,6 +3148,7 @@ echo strrev("Hello world!"); // outputs "!dlrow olleH" the difference: + @@ -3133,7 +3203,9 @@ if (is_string($pos) && !$pos) { The line of code: + will assign 2 to $var, because the string "42" will @@ -3182,9 +3254,11 @@ $var = strspn("42 is the answer, what is the question ...", "1234567890"); <function>strstr</function> example + @@ -3218,12 +3292,14 @@ print $domain; // prints @designmultimedia.com <function>strtok</function> example +"; + echo "Word=$tok
"; $tok = strtok(" "); } +]]>
@@ -3273,9 +3349,11 @@ while ($tok) { <function>strtolower</function> example + @@ -3311,9 +3389,11 @@ print $str; # Prints mary had a little lamb and she loved it so <function>strtoupper</function> example + @@ -3377,7 +3457,9 @@ print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO <function>str_replace</function> example -$bodytag = str_replace("%body%", "black", "<body text=%body%>"); +"); +]]> @@ -3425,7 +3507,9 @@ $bodytag = str_replace("%body%", "black", "<body text=%body%>"); <function>strtr</function> example + @@ -3442,8 +3526,10 @@ $addr = strtr($addr, " Examples: -$trans = array("hello" => "hi", "hi" => "hello"); + "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans) . "\n"; +]]> This will show: "hello all, I said hi", @@ -3494,8 +3580,10 @@ echo strtr("hi all, I said hello", $trans) . "\n"; Examples: + @@ -3507,9 +3595,11 @@ $rest = substr("abcdef", 1, 3); // returns "bcd" Examples: + @@ -3533,7 +3623,9 @@ $rest = substr("abcdef", -3, 1); // returns "d" Examples: + @@ -3568,7 +3660,9 @@ $rest = substr("abcdef", 1, -1); // returns "bcde" <function>substr_count</function> example + @@ -3624,24 +3718,26 @@ print substr_count("This is a test", "is"); // prints out 2 <function>substr_replace</function> example -<?php +\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) . "
\n"; +echo substr_replace($var, 'bob', 0, strlen($var)) . "
\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) . "
\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) . "
\n"; +echo substr_replace($var, 'bob', -7, -1) . "
\n"; /* Delete 'MNRPQR' from $var. */ -echo substr_replace($var, '', 10, -1) . "<br>\n"; -?> +echo substr_replace($var, '', 10, -1) . "
\n"; +?> +]]>
@@ -3788,12 +3884,14 @@ $clean = trim($binary,"\0x00..\0x1F"); <function>ucfirst</function> example + @@ -3826,12 +3924,14 @@ $bar = ucfirst(strtolower($bar)); // Hello world! <function>ucwords</function> example + @@ -3965,10 +4065,12 @@ $bar = ucwords(strtolower($bar)); // Hello World! <function>wordwrap</function> example + @@ -3977,20 +4079,24 @@ echo "$newtext\n"; - + + +]]> + <function>wordwrap</function> example + @@ -3999,12 +4105,14 @@ echo "$newtext\n"; - + + +]]> + diff --git a/functions/swf.xml b/functions/swf.xml index 0c4b981516..5bd0d7698d 100644 --- a/functions/swf.xml +++ b/functions/swf.xml @@ -1,5 +1,5 @@ - + Shockwave Flash functions SWF @@ -25,7 +25,8 @@ SWF example -<?php + +]]> @@ -172,7 +174,8 @@ swf_closefile (); and saving it in a database -<?php + +]]>
@@ -1777,6 +1781,7 @@ function swf_savedata ($data) swf_addbuttonrecord function example + diff --git a/functions/uodbc.xml b/functions/uodbc.xml index 8e70706c61..431456cfc5 100644 --- a/functions/uodbc.xml +++ b/functions/uodbc.xml @@ -1,5 +1,5 @@ - + Unified ODBC functions ODBC @@ -512,15 +512,19 @@ <function>odbc_fetch_into</function> pre 4.0.6 example + or + @@ -536,14 +540,18 @@ $rc = odbc_fetch_into($res_id, 1, $my_array); <function>odbc_fetch_into</function> 4.0.6 example + or + @@ -959,8 +967,10 @@ $rc = odbc_fetch_into($res_id, $row, $my_array); the column number of the field you want; or it can be a string containing the name of the field. For example: + @@ -1105,6 +1115,7 @@ longer than 4096 bytes, the contents is not ODBC Setoption Examples + diff --git a/functions/url.xml b/functions/url.xml index 93ee50eff6..5b5d8bebc9 100644 --- a/functions/url.xml +++ b/functions/url.xml @@ -1,5 +1,5 @@ - + URL Functions URLs @@ -138,16 +138,20 @@ <function>rawurlencode</function> example 1 -echo '<a href="ftp://user:', rawurlencode('foo @+%/'), +'; +]]> Or, if you pass information in a PATH_INFO component of the URL: <function>rawurlencode</function> example 2 -echo '<a href="http://x.com/department_list_script/', +'; +]]> @@ -178,14 +182,16 @@ echo '<a href="http://x.com/department_list_script/', <function>urldecode</function> example -$a = split('&', $QUERY_STRING); +"; $i++; } +]]> @@ -226,7 +232,9 @@ while ($i < count($a)) { <function>urlencode</function> example -echo '<a href="mycgi?foo=', urlencode($userinput), '">'; +'; +]]> @@ -247,7 +255,9 @@ echo '<a href="mycgi?foo=', urlencode($userinput), '">'; <function>urlencode/htmlentities</function> example -echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'; +'; +]]> diff --git a/functions/var.xml b/functions/var.xml index 67b10f1245..c1dac2cffe 100644 --- a/functions/var.xml +++ b/functions/var.xml @@ -1,5 +1,5 @@ - + Variable Functions Variables @@ -56,6 +56,7 @@ + @@ -103,9 +105,11 @@ if (!isset($var)) { // evaluates false floatval on arrays or objects. + @@ -226,6 +230,7 @@ print $float_value_of_var; // prints 122.34343 variables. + @@ -276,6 +282,7 @@ print_r(array_keys(get_defined_vars())); generates an error. +doc)."\n"; // prints: domxml document +]]> @@ -338,9 +346,11 @@ echo get_resource_type($doc->doc)."\n";
+ @@ -715,6 +725,7 @@ import_request_variables("gP", "rvar_"); For example: + function show_var($var) { @@ -740,6 +751,7 @@ show_var($proteins) // [2]=> // string(10) "ferredoxin" // } +]]> @@ -826,6 +838,7 @@ show_var($proteins) is not equivalent to the PHP &null; constant. + @@ -880,10 +894,12 @@ print isset ($foo); // FALSE -<?php + +]]> @@ -960,6 +976,7 @@ print_r ($a); <function>serialize</function> example + @@ -1051,11 +1069,13 @@ if (!odbc_execute ($stmt, &$sqldata)) { <function>settype</function> example + @@ -1136,6 +1156,7 @@ settype($bar, "string"); // $bar is now "1" (string) <function>unserialize</function> example +serialize. @@ -1154,6 +1175,7 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp)) $session_data = array(); } } +]]> @@ -1191,6 +1213,7 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp)) <function>unset</function> example + @@ -1214,6 +1238,7 @@ unset ($foo1, $foo2, $foo3); unset was called. + The above example would output: - + + +]]> + @@ -1239,7 +1267,8 @@ bar was called. -function foo(&$bar) { + The above example would output: - + + +]]> + @@ -1265,6 +1297,7 @@ something static variable, rather than the static variable itself. + The above example would output: - + + +]]> + If you would like to unset a global variable inside of a function, you can use the $GLOBALS array to do so: + @@ -1340,8 +1378,9 @@ foo(); -<pre> -<?php + +; + +]]> diff --git a/functions/wddx.xml b/functions/wddx.xml index 66452f48b8..34414cf570 100644 --- a/functions/wddx.xml +++ b/functions/wddx.xml @@ -1,5 +1,5 @@ - + WDDX Functions WDDX @@ -24,9 +24,12 @@ Serializing a single value -<?php + + +]]> @@ -34,15 +37,18 @@ print wddx_serialize_value("PHP to WDDX packet example", "PHP packet"); This example will produce: -<wddxPacket version='1.0'><header comment='PHP packet'/><data> -<string>PHP to WDDX packet example</string></data></wddxPacket> +
+PHP to WDDX packet example +]]> Using incremental packets -<?php + +]]> This example will produce: - -<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> - + +
+3.1415926 +AustinNovato +Seattle +]]> + @@ -127,7 +136,7 @@ print $packet; wddx_serialize_vars example -<?php + The above example will produce: - -<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> - + +
1 +5.5 +blueorangeviolet +colors +]]> + diff --git a/functions/xml.xml b/functions/xml.xml index 0e79f1e47e..459da17049 100644 --- a/functions/xml.xml +++ b/functions/xml.xml @@ -1,5 +1,5 @@ - + XML parser functions XML @@ -25,9 +25,11 @@ Makefile that comes with expat does not build a library by default, you can use this make rule for that: + A source RPM package of expat can be found at &url.expat.rpm;. @@ -273,12 +275,13 @@ libexpat.a: $(OBJS) Show XML Element Structure + @@ -320,24 +324,25 @@ xml_parser_free($xml_parser); course, this example will only work with a specific XML document type. + "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 ""; } } @@ -362,6 +367,7 @@ while ($data = fread($fp, 4096)) { } } xml_parser_free($xml_parser); +]]> @@ -385,34 +391,35 @@ xml_parser_free($xml_parser); External Entity Example +$name"; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { - print " <font color=\"#009900\">$k</font>=\"<font - color=\"#990000\">$v</font>\""; + print " $k=\"$v\""; } } - print "&gt;"; + print ">"; } function endElement($parser, $name) { - print "&lt;/<font color=\"#0000cc\">$name</font>&gt;"; + print "</$name>"; } function characterData($parser, $data) { - print "<b>$data</b>"; + print "$data"; } function PIHandler($parser, $target, $data) { @@ -425,7 +432,7 @@ function PIHandler($parser, $target, $data) { if (trustedFile($parser_file[$parser])) { eval($data); } else { - printf("Untrusted PHP code: <i>%s</i>", + printf("Untrusted PHP code: %s", htmlspecialchars($data)); } break; @@ -433,11 +440,11 @@ function PIHandler($parser, $target, $data) { } 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('%s', htmlspecialchars($data)); } else { - printf('<font size="-1">%s</font>', + printf('%s', htmlspecialchars($data)); } } @@ -491,7 +498,7 @@ if (!(list($xml_parser, $fp) = new_xml_parser($file))) { die("could not open XML input"); } -print "<pre>"; +print "
";
 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 @@ while ($data = fread($fp, 4096)) {
                     xml_get_current_line_number($xml_parser)));
     }
 }
-print "</pre>";
+print "
"; print "parse complete\n"; xml_parser_free($xml_parser); -?> +?> +]]>
@@ -511,33 +519,35 @@ xml_parser_free($xml_parser); xmltest.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> + + + +]> + + Title &plainEntity; + + + + + a1b1c1 + a2c2 + a3b3c3 + + + + + &systemEntity; + + About this Document + + + + + + +]]> @@ -546,15 +556,17 @@ xml_parser_free($xml_parser); xmltest2.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> + + +]> + + + &testEnt; + + +]]> @@ -622,19 +634,20 @@ xml_parser_free($xml_parser); assumed to be methods of object. -<?php +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 @@ function tag_close($parser,$tag) { } // end of class xml $xml_parser = new xml(); -$xml_parser->parse("<A ID=\"hallo\">PHP</A>"); -?> +$xml_parser->parse("PHP"); +?> +]]> @@ -1653,8 +1667,9 @@ $xml_parser->parse("<A ID=\"hallo\">PHP</A>"); para tag, and then we parse this an print out the structures generated: - -$simple = "<para><note>simple note</note></para>"; + +simple note"; $p = xml_parser_create(); xml_parse_into_struct($p,$simple,$vals,$index); xml_parser_free($p); @@ -1662,23 +1677,25 @@ echo "Index array\n"; print_r($index); echo "\nVals array\n"; print_r($vals); +]]> When we run that code, the output will be: - + + Array ( - [0] => 0 - [1] => 2 + [0] => 0 + [1] => 2 ) - [NOTE] => Array + [NOTE] => Array ( - [0] => 1 + [0] => 1 ) ) @@ -1686,30 +1703,31 @@ Array 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 ) ) - +]]> + @@ -1722,25 +1740,27 @@ Array representing a small database of aminoacids information: moldb.xml - small database of molecular information - -<?xml version="1.0"?> -<moldb> + + + - <molecule> - <name>Alanine</name> - <symbol>ala</symbol> - <code>A</code> - <type>hydrophobic</type> - </molecule> + + Alanine + ala + A + hydrophobic + - <molecule> - <name>Lysine</name> - <symbol>lys</symbol> - <code>K</code> - <type>charged</type> - </molecule> + + Lysine + lys + K + charged + -</moldb> + +]]> And some code to parse the document and generate the appropriate @@ -1751,7 +1771,8 @@ Array molecular objects -<?php +$v) + $this->$k = $aa[$k]; } } @@ -1775,12 +1796,12 @@ function readDatabase($filename) { 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 readDatabase($filename) { } 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 @@ $db = readDatabase("moldb.xml"); echo "** Database of AminoAcid objects:\n"; print_r($db); -?> +?> +]]> After executing parsemoldb.php, the variable @@ -1810,28 +1832,30 @@ print_r($db); AminoAcid objects, and the output of the script confirms that: - + + 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 ) ) - +]]> + diff --git a/functions/xslt.xml b/functions/xslt.xml index a0f1ac45c8..cae231f248 100644 --- a/functions/xslt.xml +++ b/functions/xslt.xml @@ -1,5 +1,5 @@ - + XSLT functions XSLT @@ -262,7 +262,8 @@ Transforming output through an XSLT stylesheet, using the DOM-XML functions for xml generation -<?php +new_child('body', 'Back after WWI, Italy gained South Tyrol from echo $doc->dumpmem(); xslt_output_endtransform(); +]]> @@ -339,48 +341,49 @@ xslt_output_endtransform(); Using the <function>xslt_process</function> to transform three strings -<?php + -<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/> + +

+

+
- <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> +$xmlData = ' +
+ Learning German + Sterling Hughes +

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>'; +
+ K#246;nnen Sie mir sagen, wo die Toilette ist?
+ Ein grosses Bier, bitte!
+ Noch eins, bitte.
+

+
'; if (xslt_process($xslData, $xmlData, $result)) { echo "Here is the brilliant in-depth article on learning"; echo " German: "; - echo "<br>\n<br>"; + echo "
\n
"; echo $result; } else { echo "There was an error that occurred in the XSL transformation...\n"; @@ -389,6 +392,7 @@ if (xslt_process($xslData, $xmlData, $result)) { exit; } ?> +]]>
diff --git a/functions/yaz.xml b/functions/yaz.xml index 38ac08cbe9..9d0b202431 100644 --- a/functions/yaz.xml +++ b/functions/yaz.xml @@ -1,5 +1,5 @@ - + YAZ functions YAZ @@ -39,7 +39,8 @@ - + + @@ -71,33 +73,34 @@ make install host. + + GILS test - <input type="checkbox" - name="host[]" value="localhost:9999/Default"> + local test - <input type="checkbox" checked="1" - name="host[]" value="z3950.bell-labs.com/books"> + BELL Labs Library - <br> +
RPN Query: - <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) . '
'; + 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 '
' . $host[$i] . ":"; $error = yaz_error($id[$i]); if (!empty($error)) { echo "Error: $error"; @@ -105,17 +108,18 @@ if (empty($term) || count($host) == 0) { $hits = yaz_hits($id[$i]); echo "Result Count $hits"; } - echo '<dl>'; - for ($p = 1; $p <= 10; $p++) { + echo '
'; + 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 "
$p
"; + echo ereg_replace("\n", "
\n",$rec); + echo "
"; } - echo '</dl>'; + echo '
'; } } +]]>
@@ -650,29 +654,31 @@ element set names. For those, piggyback should be disabled. PHP function that scans titles +<table><tr><td>'; + echo '
"; } - echo '</table>'; + echo '
'; while(list($key,list($k, $term, $tcount))=each($ar)) { if (empty($k)) continue; - echo "<tr><td>$term</td><td>"; + echo "
$term"; echo $tcount; - echo "</td></tr>"; + echo "
'; } else { - echo "Scan failed. Error: " . yaz_error($id) . "<br>"; + echo "Scan failed. Error: " . yaz_error($id) . "
"; } } +]]>
@@ -748,10 +754,12 @@ element set names. For those, piggyback should be disabled. target ID. + diff --git a/functions/zip.xml b/functions/zip.xml index 878ff21653..0280b8a717 100644 --- a/functions/zip.xml +++ b/functions/zip.xml @@ -1,5 +1,5 @@ - + Zip File Functions (Read Only Access) Zip @@ -41,7 +41,8 @@ Zip Usage Example -<?php + +]]> diff --git a/functions/zlib.xml b/functions/zlib.xml index 30145b8092..60372818cd 100644 --- a/functions/zlib.xml +++ b/functions/zlib.xml @@ -1,5 +1,5 @@ - + Zlib Compression Functions Zlib @@ -40,11 +40,12 @@ Small Zlib Example - -<?php + +\n<head></head>\n<body>\n<pre>\n"; +print "\n\n\n
\n";
 $s = "Only a test, test, test, test, test, test, test, test!\n";
 
 // open file for writing with maximum compression
@@ -72,9 +73,10 @@ if (readgzfile($filename) != strlen($s)) {
         echo "Error with zlib functions!";
 }
 unlink($filename);
-print "</pre>\n</h1></body>\n</html>\n";
+print "
\n\n\n"; ?> +]]>
@@ -314,7 +316,9 @@ print "</pre>\n</h1></body>\n</html>\n"; <function>gzopen</function> Example + @@ -405,11 +409,13 @@ $fp = gzopen ("/tmp/file.gz", "r"); + @@ -787,13 +793,15 @@ gzclose ($zd); Creating a gzip file -<?php + +]]>