From 4a6f22f50a52c401165cdc427abc61e43e2279f9 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Sun, 18 Nov 2001 03:07:18 +0000 Subject: [PATCH] started to wrap up all environments in CDATA sections to allow verbatim examples having to use entities for &, < and > makes the code hard to read and errors might slip in during the process, so the two extra lines should be worth the effort git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@62672 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/apache.xml | 4 +- functions/array.xml | 272 ++++++++++++++++++++++++++++++--------- functions/aspell.xml | 12 +- functions/bzip2.xml | 42 ++++-- functions/calendar.xml | 10 +- functions/classobj.xml | 140 +++++++++++--------- functions/com.xml | 10 +- functions/cpdf.xml | 38 ++++-- functions/curl.xml | 10 +- functions/cybermut.xml | 25 ++-- functions/datetime.xml | 36 +++++- functions/dba.xml | 16 ++- functions/dbase.xml | 12 +- functions/dbm.xml | 6 +- functions/dbx.xml | 106 ++++++++------- functions/dir.xml | 28 ++-- functions/domxml.xml | 94 +++++++------- functions/errorfunc.xml | 90 +++++++------ functions/exec.xml | 6 +- functions/fbsql.xml | 182 +++++++++++++++++--------- functions/fdf.xml | 34 +++-- functions/filesystem.xml | 70 ++++++++-- functions/ftp.xml | 8 +- functions/funchand.xml | 112 +++++++++------- functions/gettext.xml | 6 +- functions/gmp.xml | 18 ++- functions/http.xml | 34 ++++- functions/hw.xml | 36 +++++- functions/ibase.xml | 26 +++- functions/iconv.xml | 8 +- functions/ifx.xml | 70 ++++++---- functions/image.xml | 79 +++++++++--- functions/imap.xml | 143 ++++++++++++-------- functions/info.xml | 136 +++++++++++++------- functions/ingres_ii.xml | 28 +++- functions/ircg.xml | 4 +- functions/java.xml | 44 ++++--- functions/ldap.xml | 96 ++++++++------ functions/mail.xml | 52 +++++--- functions/math.xml | 22 +++- functions/mbstring.xml | 64 +++++++-- 41 files changed, 1506 insertions(+), 723 deletions(-) diff --git a/functions/apache.xml b/functions/apache.xml index 6d688b3922..37a66fd42a 100644 --- a/functions/apache.xml +++ b/functions/apache.xml @@ -1,5 +1,5 @@ - + Apache-specific Functions Apache @@ -173,10 +173,12 @@ <function>getallheaders</function> Example + diff --git a/functions/array.xml b/functions/array.xml index abda7db57d..20e346df78 100644 --- a/functions/array.xml +++ b/functions/array.xml @@ -1,5 +1,5 @@ - + Array Functions Arrays @@ -72,11 +72,13 @@ <function>array</function> example + array ("a"=>"orange", "b"=>"banana", "c"=>"apple"), + "numbers" => array (1, 2, 3, 4, 5, 6), + "holes" => array ("first", 5 => "second", "third") ); +]]> @@ -84,13 +86,16 @@ $fruits = array ( Automatic index with <function>array</function> +1, 4=>1, 19, 3=>13); print_r($array); +]]> which will display : + 1 @@ -101,6 +106,7 @@ Array [8] => 1 [9] => 19 ) +]]> Note that index '3' is defined twice, and keep its final value of 13. @@ -112,19 +118,23 @@ Array 1-based index with <function>array</function> + 'January', 'February', 'March'); print_r($firstquarter); +]]> which will display : + 'January' [2] => 'February' [3] => 'March' ) +]]> @@ -163,18 +173,22 @@ Array <function>array_change_key_case</function> example + 1, "SecOnd" => 4); print_r(array_change_key_case($input_array, CASE_UPPER); +]]> The printout of the above program will be: + 1 [SECOND] => 2 ) +]]> @@ -215,14 +229,17 @@ Array <function>array_chunk</function> example + The printout of the above program will be: + Array @@ -263,6 +280,7 @@ Array ) ) +]]> @@ -291,8 +309,10 @@ Array <function>array_count_values</function> example +2, "hello"=>2, "world"=>1) +]]> @@ -326,9 +346,11 @@ array_count_values ($array); // returns array (1=>2, "hello"=>2, "world"=& <function>array_diff</function> example -$array1 = array ("a" => "green", "red", "blue", "red"); -$array2 = array ("b" => "green", "yellow", "red"); + "green", "red", "blue", "red"); +$array2 = array ("b" => "green", "yellow", "red"); $result = array_diff ($array1, $array2); +]]> @@ -386,6 +408,7 @@ $result = array_diff ($array1, $array2); <function>array_filter</function> example +1, "b"=>2, "c"=>3, "d"=>4, "e"=>5); $array2 = array (6, 7, 8, 9, 10, 11, 12); $odd_arr = array_filter($array1, "odd"); $even_arr = array_filter($array2, "even"); +]]> @@ -452,8 +476,10 @@ $even_arr = array_filter($array2, "even"); <function>array_flip</function> example + @@ -461,9 +487,11 @@ $original = strtr ($str, $trans); <function>array_flip</function> example : collision + 1, "b" => 1, "c" => 2); $trans = array_flip ($trans); // now $trans is : array(1 => "b", 2 => "c"); +]]> @@ -495,6 +523,7 @@ $trans = array_flip ($trans); <function>array_fill</function> example + @@ -540,9 +570,11 @@ $a[10] = "banana"; <function>array_intersect</function> example -$array1 = array ("a" => "green", "red", "blue"); -$array2 = array ("b" => "green", "yellow", "red"); + "green", "red", "blue"); +$array2 = array ("b" => "green", "yellow", "red"); $result = array_intersect ($array1, $array2); +]]> @@ -594,10 +626,12 @@ $result = array_intersect ($array1, $array2); <function>array_key_exists</function> example + 1, "second" => 4); if (array_key_exists("first", $search_array)) { echo "The 'first' element is in the array"; } +]]> @@ -644,14 +678,16 @@ if (array_key_exists("first", $search_array)) { <function>array_keys</function> example -$array = array (0 => 100, "color" => "red"); + 100, "color" => "red"); array_keys ($array); // returns array (0, "color") $array = array ("blue", "red", "green", "blue", "blue"); array_keys ($array, "blue"); // returns array (0, 3, 4) -$array = array ("color" => array("blue", "red", "green"), "size" => array("small", "medium", "large")); +$array = array ("color" => array("blue", "red", "green"), "size" => array("small", "medium", "large")); array_keys ($array); // returns array ("color", "size") +]]> @@ -665,16 +701,18 @@ array_keys ($array); // returns array ("color", "size") users + @@ -715,12 +753,14 @@ function array_keys ($arr, $term="") { <function>array_map</function> example + @@ -732,6 +772,7 @@ $b = array_map("cube", $a); <function>array_map</function> - using more arrays + @@ -809,6 +851,7 @@ print_r($d); Creating an array of arrays + @@ -897,9 +941,11 @@ print_r($d); <function>array_merge</function> example -$array1 = array ("color" => "red", 2, 4); -$array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid", 4); + "red", 2, 4); +$array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid", 4); array_merge ($array1, $array2); +]]> @@ -947,9 +993,11 @@ array_merge ($array1, $array2); <function>array_merge_recursive</function> example -$ar1 = array ("color" => array ("favorite" => "red"), 5); -$ar2 = array (10, "color" => array ("favorite" => "green", "blue")); + array ("favorite" => "red"), 5); +$ar2 = array (10, "color" => array ("favorite" => "green", "blue")); $result = array_merge_recursive ($ar1, $ar2); +]]> @@ -1042,9 +1090,11 @@ $result = array_merge_recursive ($ar1, $ar2); Sorting multiple arrays + @@ -1058,9 +1108,11 @@ array_multisort ($ar1, $ar2); Sorting multi-dimensional array + @@ -1105,6 +1157,7 @@ array_multisort ($ar[0], SORT_ASC, SORT_STRING, <function>array_pad</function> example + @@ -1145,8 +1199,10 @@ $result = array_pad ($input, 2, "noop"); <function>array_pop</function> example + @@ -1189,7 +1245,9 @@ $fruit = array_pop ($stack); length of array increases by the number of variables pushed. Has the same effect as: + repeated for each var. @@ -1200,8 +1258,10 @@ $array[] = $var; <function>array_push</function> example + @@ -1256,11 +1316,13 @@ array_push ($stack, "+", 3); <function>array_rand</function> example + @@ -1295,9 +1357,11 @@ print $input[$rand_keys[1]]."\n"; <function>array_reverse</function> example + @@ -1348,6 +1412,7 @@ $result_keyed = array_reverse ($input, TRUE); <function>array_reduce</function> example + @@ -1405,8 +1471,10 @@ $d = array_reduce($x, "rsum", 1); <function>array_shift</function> example + @@ -1466,12 +1534,14 @@ $opt = array_shift ($args); <function>array_slice</function> examples + @@ -1548,12 +1618,14 @@ $output = array_slice ($input, 0, 3); // returns "a", "b", and "c" The following equivalences hold: + @@ -1563,6 +1635,7 @@ $a[$x] = $y array_splice ($input, $x, 1, $y) <function>array_splice</function> examples + @@ -1611,6 +1685,7 @@ array_splice ($input, -1, 1, array("black", "maroon")); <function>array_sum</function> examples +1.2,"b"=>2.3,"c"=>3.4); echo "sum(b) = ".array_sum($b)."\n"; // prints: sum(b) = 6.9 +]]> @@ -1668,7 +1744,8 @@ echo "sum(b) = ".array_sum($b)."\n"; <function>array_unique</function> example -$input = array ("a" => "green", "red", "b" => "green", "blue", "red"); + "green", "red", "b" => "green", "blue", "red"); $result = array_unique ($input); print_r($result); // this will output : @@ -1678,6 +1755,7 @@ print_r($result); // [0] => red // [1] => blue //) +]]> @@ -1685,6 +1763,7 @@ print_r($result); <function>array_unique</function> and types + @@ -1738,8 +1818,10 @@ array(2) { <function>array_unshift</function> example + @@ -1776,8 +1858,10 @@ array_unshift ($queue, "p4", "p5", "p6"); <function>array_values</function> example -$array = array ("size" => "XL", "color" => "gold"); + "XL", "color" => "gold"); array_values ($array); // returns array ("XL", "gold") +]]> @@ -1791,6 +1875,7 @@ array_values ($array); // returns array ("XL", "gold") users + @@ -1869,14 +1955,15 @@ function array_values ($arr) { <function>array_walk</function> example -$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); -function test_alter (&$item1, $key, $prefix) { +function test_alter (&$item1, $key, $prefix) { $item1 = "$prefix: $item1"; } function test_print ($item2, $key) { - echo "$key. $item2<br>\n"; + echo "$key. $item2
\n"; } array_walk ($fruits, 'test_print'); @@ -1884,6 +1971,7 @@ reset ($fruits); array_walk ($fruits, 'test_alter', 'fruit'); reset ($fruits); array_walk ($fruits, 'test_print'); +]]>
@@ -1919,12 +2007,14 @@ array_walk ($fruits, 'test_print'); <function>arsort</function> example -$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); arsort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } +]]> @@ -1934,10 +2024,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -1981,12 +2073,14 @@ c = apple <function>asort</function> example -$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); asort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } +]]> @@ -1996,10 +2090,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -2059,6 +2155,7 @@ a = orange <function>compact</function> example + After this, $result will be array @@ -2121,6 +2219,7 @@ $result = compact ("event", "nothing_here", $location_vars); <function>count</function> example + @@ -2228,8 +2328,10 @@ $result = count ($b); <function>each</function> examples + $bar now contains the following key/value @@ -2241,8 +2343,10 @@ $bar = each ($foo); value => 'bob' -$foo = array ("Robert" => "Bob", "Seppo" => "Sepi"); + "Bob", "Seppo" => "Sepi"); $bar = each ($foo); +]]> @@ -2267,11 +2371,13 @@ $bar = each ($foo); each -echo "Values submitted via POST method:<br>"; +"; reset ($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) { - echo "$key => $val<br>"; + echo "$key => $val
"; } +]]>
@@ -2432,27 +2538,31 @@ while (list ($key, $val) = each ($HTTP_POST_VARS)) { <function>extract</function> example -<?php + "blue", + "size" => "medium", + "shape" => "sphere"); extract ($var_array, EXTR_PREFIX_SAME, "wddx"); print "$color, $size, $shape, $wddx_size\n"; ?> +]]> The above example will produce: + @@ -2508,10 +2618,12 @@ blue, large, sphere, medium <function>in_array</function> example + @@ -2519,18 +2631,20 @@ if (in_array ("Irix", $os)) { <function>in_array</function> with strict example -<?php + // This will output: 1.13 found with strict check +]]> @@ -2620,12 +2734,14 @@ if (in_array(1.13, $a, TRUE)) <function>krsort</function> example -$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); krsort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } +]]> @@ -2635,10 +2751,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -2677,12 +2795,14 @@ a = orange <function>ksort</function> example -$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } +]]> @@ -2692,10 +2812,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -2739,25 +2861,27 @@ d = lemon <function>list</function> example -<table> - <tr> - <th>Employee name</th> - <th>Salary</th> - </tr> + + + Employee name + Salary + -<?php +\n". - " <td><a href=\"info.php3?id=$id\">$name</a></td>\n". - " <td>$salary</td>\n". - " </tr>\n"); + print (" \n". + " $name\n". + " $salary\n". + " \n"); } ?> -</table> + +]]> @@ -2793,6 +2917,7 @@ while (list ($id, $name, $salary) = mysql_fetch_row ($result)) { <function>natsort</function> example + @@ -2811,23 +2937,25 @@ print_r($array2); + img1.png + [1] => img10.png + [2] => img12.png + [3] => img2.png ) Natural order sorting Array ( - [3] => img1.png - [2] => img2.png - [1] => img10.png - [0] => img12.png + [3] => img1.png + [2] => img2.png + [1] => img10.png + [0] => img12.png ) +]]> For more information see: Martin Pool's <function>range</function> examples + @@ -3090,12 +3220,14 @@ foreach(range('z', 'a') as $letter) { <function>rsort</function> example + @@ -3105,10 +3237,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -3148,12 +3282,14 @@ while (list ($key, $val) = each ($fruits)) { <function>shuffle</function> example + @@ -3210,7 +3346,8 @@ while (list (, $number) = each ($numbers)) { <function>sort</function> example -<?php + +]]> @@ -3229,10 +3367,12 @@ while (list ($key, $val) = each ($fruits)) { + @@ -3339,18 +3479,20 @@ fruits[3] = orange <function>uksort</function> example + $b) ? -1 : 1; } -$a = array (4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); +$a = array (4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); uksort ($a, "cmp"); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } +]]> @@ -3360,10 +3502,12 @@ while (list ($key, $value) = each ($a)) { + @@ -3409,9 +3553,10 @@ while (list ($key, $value) = each ($a)) { <function>usort</function> example + $b) ? -1 : 1; } $a = array (3, 2, 5, 6, 1); @@ -3421,6 +3566,7 @@ usort ($a, "cmp"); while (list ($key, $value) = each ($a)) { echo "$key: $value\n"; } +]]> @@ -3430,11 +3576,13 @@ while (list ($key, $value) = each ($a)) { + @@ -3450,6 +3598,7 @@ while (list ($key, $value) = each ($a)) { usort example using multi-dimensional array + @@ -3476,9 +3626,11 @@ while (list ($key, $value) = each ($fruits)) { + diff --git a/functions/aspell.xml b/functions/aspell.xml index 87b2e5805f..56635beef9 100644 --- a/functions/aspell.xml +++ b/functions/aspell.xml @@ -1,5 +1,5 @@ - + Aspell functions [deprecated] Aspell @@ -50,7 +50,9 @@ <function>aspell_new</function> + @@ -79,6 +81,7 @@ $aspell_link = aspell_new("english"); <function>aspell_check</function> + @@ -117,6 +121,7 @@ if (aspell_check($aspell_link, "testt")) { <function>aspell_check_raw</function> + @@ -152,15 +158,17 @@ if (aspell_check_raw($aspell_link, "test")) { <function>aspell_suggest</function> +\n"; + echo "Possible spelling: $suggestion
\n"; } } +]]>
diff --git a/functions/bzip2.xml b/functions/bzip2.xml index 7ef1a1ddac..e0fb13c92b 100644 --- a/functions/bzip2.xml +++ b/functions/bzip2.xml @@ -1,5 +1,5 @@ - + Bzip2 Compression Functions Bzip2 @@ -25,7 +25,8 @@ Small bzip2 Example -<?php + +]]> @@ -129,11 +131,14 @@ bzclose($bz); <function>bzcompress</function> Example - <?php + + +]]> @@ -173,19 +178,22 @@ print( $bzstr ); <function>bzdecompress</function> - <?php + +\n" ); $str = bzdecompress($bzstr); print( "Decompressed String: " ); print( $str ); -print( "\n<br>n" ); +print( "\n
\n" ); ?> +]]>
@@ -241,12 +249,15 @@ print( "\n<br>n" ); <function>bzerror</function> Example - <?php + + +]]> @@ -335,15 +346,18 @@ echo $error["errstr"]; <function>bzopen</function> Example - <?php + +\n" ); print( $decompressed_file ); ?> +]]> @@ -383,11 +397,14 @@ print( $decompressed_file ); <function>bzread</function> Example - <?php + + +]]> @@ -426,12 +443,15 @@ print( $str ); <function>bzwrite</function> Example - <?php + + +]]> diff --git a/functions/calendar.xml b/functions/calendar.xml index 01e56b1fde..c66ece9828 100644 --- a/functions/calendar.xml +++ b/functions/calendar.xml @@ -1,5 +1,5 @@ - + Calendar functions Calendar @@ -76,12 +76,14 @@ Calendar functions -<?php + +]]> @@ -385,9 +387,11 @@ echo "$gregorian\n"; <function>easter_date</function> example + @@ -446,9 +450,11 @@ echo date ("M-d-Y", easter_date(2001)); /* "Apr-15-2001" */ <function>easter_days</function> example + diff --git a/functions/classobj.xml b/functions/classobj.xml index 2af5b13acf..481f52cdfe 100644 --- a/functions/classobj.xml +++ b/functions/classobj.xml @@ -1,5 +1,5 @@ - + Class/Object Functions Classes/Objects @@ -31,7 +31,8 @@ classes.inc -<?php +edible = $edible; + $this->color = $color; } function is_edible() { - return $this->edible; + return $this->edible; } function what_color() { - return $this->color; + return $this->color; } } // end of class Vegetable @@ -61,20 +62,21 @@ class Spinach extends Vegetable { var $cooked = false; function Spinach() { - $this->Vegetable( true, "green" ); + $this->Vegetable( true, "green" ); } function cook_it() { - $this->cooked = true; + $this->cooked = true; } function is_cooked() { - return $this->cooked; + return $this->cooked; } } // end of class Spinach -?> +?> +]]> @@ -88,58 +90,60 @@ class Spinach extends Vegetable { test_script.php -<pre> -<?php + + + +]]> @@ -153,10 +157,12 @@ class_parentage("leafy", "Vegetable"); + @@ -244,30 +250,32 @@ Object leafy belongs to class spinach a subclass of Vegetable print_info method. -<?php +NAME = $name; + $this->TLD = $tld; } - function print_info($prestr="") { - echo $prestr."Country: ".$this->NAME."\n"; - echo $prestr."Top Level Domain: ".$this->TLD."\n"; + function print_info($prestr="") { + echo $prestr."Country: ".$this->NAME."\n"; + echo $prestr."Top Level Domain: ".$this->TLD."\n"; } } -$cntry = new Country("Peru","pe"); +$cntry = new Country("Peru","pe"); -echo "* Calling the object method directly\n"; -$cntry->print_info(); +echo "* Calling the object method directly\n"; +$cntry->print_info(); -echo "\n* Calling the same method indirectly\n"; -call_user_method ("print_info", $cntry, "\t"); -?> +echo "\n* Calling the same method indirectly\n"; +call_user_method ("print_info", $cntry, "\t"); +?> +]]> @@ -353,7 +361,9 @@ call_user_method ("print_info", $cntry, "\t"); class_name. For example: + @@ -362,7 +372,8 @@ $class_methods = get_class_methods($my_class); <function>get_class_methods</function> example -<?php + +]]> @@ -397,9 +409,11 @@ foreach ($class_methods as $method_name) { Will produce: + @@ -440,7 +454,8 @@ myfunc2 <function>get_class_vars</function> example -<?php + $value) { echo "$name : $value\n"; } -?> +?> +]]> @@ -471,8 +487,10 @@ foreach ($class_vars as $name => $value) { Will produce: + @@ -540,24 +558,25 @@ var3 : 100 Use of <function>get_object_vars</function> -<?php +x = $x; + $this->y = $y; } function setLabel($label) { - $this->label = $label; + $this->label = $label; } function getPoint() { - return array("x" => $this->x, - "y" => $this->y, - "label" => $this->label); + return array("x" => $this->x, + "y" => $this->y, + "label" => $this->label); } } @@ -566,20 +585,21 @@ print_r(get_object_vars($p1)); // "$label" is declared but not defined // Array // ( -// [x] => 1.233 -// [y] => 3.445 +// [x] => 1.233 +// [y] => 3.445 // ) -$p1->setLabel("point #1"); +$p1->setLabel("point #1"); print_r(get_object_vars($p1)); // Array // ( -// [x] => 1.233 -// [y] => 3.445 -// [label] => point #1 +// [x] => 1.233 +// [y] => 3.445 +// [label] => point #1 // ) -?> +?> +]]> diff --git a/functions/com.xml b/functions/com.xml index d9646060e1..3194ef0608 100644 --- a/functions/com.xml +++ b/functions/com.xml @@ -1,5 +1,5 @@ - + COM support functions for Windows COM @@ -85,6 +85,7 @@ COM example (1) +Version}\n"; @@ -105,6 +106,7 @@ $word->Quit(); //free the object $word->Release(); $word = null; +]]> @@ -112,6 +114,7 @@ $word = null; COM example (2) +Open("Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=database; User ID=user; Password=password"); @@ -121,7 +124,7 @@ $rs = $conn->Execute("SELECT * FROM sometable"); // Recordset $num_columns = $rs->Fields->Count(); echo $num_columns . "\n"; -for ($i=0; $i < $num_columns; $i++) +for ($i=0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } @@ -129,7 +132,7 @@ for ($i=0; $i < $num_columns; $i++) $rowcount = 0; while (!$rs->EOF) { - for ($i=0; $i < $num_columns; $i++) + for ($i=0; $i < $num_columns; $i++) { echo $fld[$i]->value . "\t"; } @@ -146,6 +149,7 @@ $conn->Release(); $rs = null; $conn = null; +]]> diff --git a/functions/cpdf.xml b/functions/cpdf.xml index 3ccff4400a..ced4b252dc 100644 --- a/functions/cpdf.xml +++ b/functions/cpdf.xml @@ -1,5 +1,5 @@ - + ClibPDF functions ClibPDF @@ -63,7 +63,8 @@ Simple ClibPDF Example -<?php + +]]> @@ -90,7 +92,8 @@ cpdf_close($cpdf); pdfclock example from pdflib 2.0 distribution -<?php + +]]> @@ -238,7 +242,8 @@ cpdf_close($pdf); Adding a page outline -<?php + +]]> @@ -314,12 +320,14 @@ cpdf_close($cpdf); Text output -<?php + +]]> @@ -573,12 +581,14 @@ cpdf_end_text($pdf) Text output -<?php + +]]> @@ -1069,11 +1079,13 @@ cpdf_end_text($pdf) Save/Restore -<?php + +]]> diff --git a/functions/curl.xml b/functions/curl.xml index 3671721160..c220f98924 100644 --- a/functions/curl.xml +++ b/functions/curl.xml @@ -1,5 +1,5 @@ - + CURL, Client URL Library Functions CURL @@ -45,7 +45,8 @@ Using PHP's CURL module to fetch the PHP homepage -<?php + +]]> @@ -95,7 +97,8 @@ fclose ($fp); Initializing a new CURL session and fetching a webpage -<?php + +]]> diff --git a/functions/cybermut.xml b/functions/cybermut.xml index abcab0d6e3..822645e94b 100755 --- a/functions/cybermut.xml +++ b/functions/cybermut.xml @@ -1,5 +1,5 @@ - + Crédit Mutuel CyberMUT functions CyberMUT @@ -73,7 +73,8 @@ First step of payment (equiv cgi1.c) -<?php + +]]> @@ -135,16 +137,19 @@ $VERSION="1.2"; Pay attention to parameters code-retour and texte-libre, which cannot be evaluated as is, because auf the dash. You must retrieve them by using: -<?php + +]]> Last step of payment (equiv cgi2.c) -<?php + +]]> diff --git a/functions/datetime.xml b/functions/datetime.xml index 636c86c56e..78380c1365 100644 --- a/functions/datetime.xml +++ b/functions/datetime.xml @@ -1,5 +1,5 @@ - + Date and Time functions Date/time @@ -254,8 +254,10 @@ <function>date</function> example + @@ -267,7 +269,9 @@ echo "July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000)); Escaping characters in <function>date</function> + @@ -280,10 +284,12 @@ echo date("l \\t\h\e jS"); // prints something like 'Saturday the 8th' date and mktime example - + + @@ -305,7 +311,8 @@ $nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1); <function>date</function> Formatting - + + @@ -408,12 +416,14 @@ $today = date("H:i:s"); // 17:16:17 <function>getdate</function> example - + + @@ -487,8 +497,10 @@ echo "$month $mday, $year"; <function>gmdate</function> example + @@ -554,9 +566,11 @@ echo gmdate ("M d Y H:i:s", mktime (0,0,0,1,1,1998)); <function>gmstrftime</function> example + @@ -678,6 +692,7 @@ echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n"; <function>microtime</function> example + @@ -759,11 +775,13 @@ echo "Did nothing in $time seconds"; lines produces the string "Jan-01-1998". <function>mktime</function> example - + + Year may be a two or four digit value, @@ -779,11 +797,13 @@ echo date ("M-d-Y", mktime (0,0,0,1,1,98)); Last day of next month + @@ -1022,6 +1042,7 @@ echo strftime ("Last day in Feb 2000 is: %d", $lastday); <function>strftime</function> example + This example works if you have the respective locales installed @@ -1093,11 +1115,13 @@ print (strftime ("%A.\n")); <function>strtotime</function> examples + diff --git a/functions/dba.xml b/functions/dba.xml index 9e5f73035b..4d5c6cdc50 100644 --- a/functions/dba.xml +++ b/functions/dba.xml @@ -1,5 +1,5 @@ - + Database (dbm-style) abstraction layer functions dba @@ -106,7 +106,8 @@ DBA example -<?php + +]]> @@ -147,7 +149,8 @@ dba_close ($id); Traversing a database -<?php + +]]> diff --git a/functions/dbase.xml b/functions/dbase.xml index 300f7355e7..8a6347136f 100644 --- a/functions/dbase.xml +++ b/functions/dbase.xml @@ -1,5 +1,5 @@ - + dBase functions dBase @@ -104,6 +104,7 @@ Creating a dBase database file +Error!</strong>"; + print "Error!"; +]]> @@ -351,11 +353,13 @@ if (!dbase_create($dbname, $def)) Using <function>dbase_numfields</function> +\n"; +for ($i=0; $i < $nf; $i++) { + print $rec[$i]."
\n"; } +]]>
diff --git a/functions/dbm.xml b/functions/dbm.xml index 74f53f1785..0a0692999d 100644 --- a/functions/dbm.xml +++ b/functions/dbm.xml @@ -1,5 +1,5 @@ - + DBM Functions DBM @@ -16,6 +16,7 @@ DBM example + @@ -263,11 +265,13 @@ dbmclose ($dbm); Visiting every key/value pair in a DBM database + diff --git a/functions/dbx.xml b/functions/dbx.xml index 0a375c011c..850093fc2e 100644 --- a/functions/dbx.xml +++ b/functions/dbx.xml @@ -1,5 +1,5 @@ - + dbx functions dbx @@ -53,12 +53,14 @@ <function>dbx_close</function> example -<?php + +]]> @@ -146,10 +148,12 @@ dbx_close($link); -<?php +handle); // dbx_close($link) would be better here -?> +?> +]]> @@ -162,12 +166,14 @@ mysql_close ($link->handle); // dbx_close($link) would be better here <function>dbx_connect</function> example -<?php + +]]> @@ -212,7 +218,8 @@ dbx_close ($link); <function>dbx_error</function> example -<?php + +]]> @@ -292,8 +300,10 @@ dbx_close ($link); +handle, 0); +]]> @@ -304,8 +314,10 @@ mysql_field_len ($result->handle, 0); +rows . " x " . $result->cols . "<br>\n"; +echo "result size: " . $result->rows . " x " . $result->cols . "
\n"; +]]>
@@ -318,9 +330,11 @@ echo "result size: " . $result->rows . " x " . $result->cols . "<br>\n"; +info["name"][0] . "<br>\n"; -echo "column type: " . $result->info["type"][0] . "<br>\n"; +echo "column name: " . $result->info["name"][0] . "
\n"; +echo "column type: " . $result->info["type"][0] . "
\n"; +]]>
@@ -333,42 +347,44 @@ echo "column type: " . $result->info["type"][0] . "<br>\n"; <function>dbx_query</function> example -<?php +"; +if ($result==0) echo "Query failed\n
"; elseif ($result==1) { - echo "Query executed successfully\n<br>"; + echo "Query executed successfully\n
"; } else { $rows=$result->rows; $cols=$result->cols; - echo "<p>table dimension: {$result->rows} x {$result->cols}<br><table border=1>\n"; - echo "<tr>"; - for ($col=0; $col<$cols; ++$col) { - echo "<td>-{$result->info["name"][$col]}-<br>-{$result->info["type"][$col]}-</td>"; + echo "

table dimension: {$result->rows} x {$result->cols}
\n"; + echo ""; + for ($col=0; $col<$cols; ++$col) { + echo ""; } - echo "</tr>\n"; - for ($row=0; $row<$rows; ++$row){ - echo "<tr>"; - for ($col=0; $col<$cols; ++$col) { - echo "<td>-{$result->data[$row][$col]}-</td>"; + echo "\n"; + for ($row=0; $row<$rows; ++$row){ + echo ""; + for ($col=0; $col<$cols; ++$col) { + echo ""; } - echo "</tr>\n"; + echo "\n"; } - echo "</table><p>\n"; - echo "table dimension: {$result->rows} x id, parentid, description<br><table border=1>\n"; - for ($row=0; $row<$rows; ++$row) { - echo "<tr>"; - echo "<td>-{$result->data[$row]["id"]}-</td>"; - echo "<td>-{$result->data[$row]["parentid"]}-</td>"; - echo "<td>-{$result->data[$row]["description"]}-</td>"; - echo "</tr>\n"; + echo "
-{$result->info["name"][$col]}-
-{$result->info["type"][$col]}-
-{$result->data[$row][$col]}-

\n"; + echo "table dimension: {$result->rows} x id, parentid, description
\n"; + for ($row=0; $row<$rows; ++$row) { + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; } - echo "</table><p>\n"; + echo "
-{$result->data[$row]["id"]}--{$result->data[$row]["parentid"]}--{$result->data[$row]["description"]}-

\n"; } dbx_close($link); -?> +?> +]]> @@ -408,7 +424,8 @@ dbx_close($link); <function>dbx_sort</function> example -<?php +"; +echo "resulting data is now ordered by id
"; dbx_sort ($result, "user_re_order"); -echo "resulting data is now ordered by parentid (descending), then by id<br>"; +echo "resulting data is now ordered by parentid (descending), then by id
"; dbx_close ($link); -?> +?> +]]>
@@ -469,7 +487,8 @@ dbx_close ($link); <function>dbx_compare</function> example -<?php +"; +echo "resulting data is now ordered by id
"; dbx_sort ($result, "user_re_order"); -echo "resulting data is now ordered by parentid (descending), then by id<br>"; +echo "resulting data is now ordered by parentid (descending), then by id
"; dbx_close ($link); -?> +?> +]]>
diff --git a/functions/dir.xml b/functions/dir.xml index c352b166a7..0b2c81e09b 100644 --- a/functions/dir.xml +++ b/functions/dir.xml @@ -1,5 +1,5 @@ - + Directory functions Directories @@ -90,13 +90,15 @@ <function>dir</function> example +handle."<br>\n"; -echo "Path: ".$d->path."<br>\n"; +echo "Handle: ".$d->handle."
\n"; +echo "Path: ".$d->path."
\n"; while ($entry = $d->read()) { - echo $entry."<br>\n"; + echo $entry."
\n"; } $d->close(); +]]>
@@ -173,7 +175,8 @@ $d->close(); <function>opendir</function> example -<?php + +]]>
@@ -208,8 +212,9 @@ if ($dir = @opendir("/tmp")) { List all files in the current directory + +]]> @@ -232,7 +238,8 @@ closedir($handle); and .. -<?php + +]]> diff --git a/functions/domxml.xml b/functions/domxml.xml index c69ec74d36..a446f1716f 100644 --- a/functions/domxml.xml +++ b/functions/domxml.xml @@ -1,5 +1,5 @@ - + DOM XML functions DOM XML @@ -523,38 +523,40 @@ Retrieving root element -<?php -$xmlstr = "<?xml version='1.0' standalone='yes'?> -<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd' -[ <!ENTITY sp \"spanish\"> + + ]> -<!-- lsfj --> -<chapter language='en'><title language='en'>Title</title> - <para language='ge'> + +Title + &sp; - <!-- comment --> - <informaltable language='&sp;'> - <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> -</chapter>"; + + + + + a1b1c1 +a2c2 + a3b3c3 + + + + +"; if(!$dom = xmldoc($xmlstr)) { echo "Error while parsing the document\n"; exit; } -$root = $dom->root(); +$root = $dom->root(); /* or $root = domxml_root($dom); */ print_r($root); -?> +?> +]]> @@ -586,13 +588,15 @@ print_r($root); Creating a simple HTML document header -<?php +add_root("HTML"); +$head = $root->new_child("HEAD", ""); +$head->new_child("TITLE", "Hier der Titel"); +echo $doc->dumpmem(); +?> +]]> @@ -704,14 +708,16 @@ echo $doc->dumpmem(); Adding an attribute to an element -<?php +add_root("HTML"); +$head = $root->new_child("HEAD", ""); +$head->new_child("TITLE", "Hier der Titel"); +$head->set_attribute("Language", "ge"); +echo $doc->dumpmem(); +?> +]]> @@ -744,14 +750,16 @@ echo $doc->dumpmem(); Adding an attribute to an element -<?php +add_root("HTML"); +$head = $root->new_child("HEAD", ""); +$head->new_child("TITLE", "Hier der Titel"); +$head->set_attribute("Language", "ge"); +$children = $head->children(); +?> +]]> diff --git a/functions/errorfunc.xml b/functions/errorfunc.xml index 2d764cff91..586f892518 100644 --- a/functions/errorfunc.xml +++ b/functions/errorfunc.xml @@ -1,5 +1,5 @@ - + Error Handling and Logging Functions Errors and Logging @@ -109,6 +109,7 @@ <function>error_log</function> examples + @@ -156,6 +158,7 @@ error_log ("You messed up!", 3, "/var/tmp/my-errors.log"); Error Integer changes + Follow the links for the internal values to get their meanings: @@ -251,6 +255,7 @@ error_reporting (E_ALL ^ E_NOTICE); // The same in both PHP 3 and 4 <function>error_reporting</function> examples + @@ -341,7 +347,8 @@ error_reporting (E_ALL); // New syntax for PHP 3/4 trigger_error -<?php +FATAL [$errno] $errstr
\n"; + echo " Fatal error in line ".$errline." of file ".$errfile; + echo ", PHP ".PHP_VERSION." (".PHP_OS.")
\n"; + echo "Aborting...
\n"; exit -1; break; case ERROR: - echo "<b>ERROR</b> [$errno] $errstr<br>\n"; + echo "ERROR [$errno] $errstr
\n"; break; case WARNING: - echo "<b>WARNING</b> [$errno] $errstr<br>\n"; + echo "WARNING [$errno] $errstr
\n"; break; default: - echo "Unkown error type: [$errno] $errstr<br>\n"; + echo "Unkown error type: [$errno] $errstr
\n"; break; } } // function to test the error handling function scale_by_log ($vect, $scale) { - if ( !is_numeric($scale) || $scale <= 0 ) - trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale", + if ( !is_numeric($scale) || $scale <= 0 ) + trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale", FATAL); if (!is_array($vect)) { - trigger_error("Incorrect input vector, array of values expected", ERROR); + trigger_error("Incorrect input vector, array of values expected", ERROR); return null; } - for ($i=0; $i<count($vect); $i++) { + for ($i=0; $i +]]>
And when you run this sample script, the output will be + 2 + [1] => 3 + [2] => foo + [3] => 5.5 + [4] => 43.3 + [5] => 21.11 ) ---- vector b - a warning (b = log(PI) * a) -<b>WARNING</b> [1024] Value at position 2 is not a number, using 0 (zero)<br> +WARNING [1024] Value at position 2 is not a number, using 0 (zero)
Array ( - [0] => 2.2894597716988 - [1] => 3.4341896575482 - [2] => 0 - [3] => 6.2960143721717 - [4] => 49.566804057279 - [5] => 24.165247890281 + [0] => 2.2894597716988 + [1] => 3.4341896575482 + [2] => 0 + [3] => 6.2960143721717 + [4] => 49.566804057279 + [5] => 24.165247890281 ) ---- vector c - an error -<b>ERROR</b> [512] Incorrect input vector, array of values expected<br> +ERROR [512] Incorrect input vector, array of values expected
NULL ---- vector d - fatal error -<b>FATAL</b> [256] log(x) for x <= 0 is undefined, you used: scale = -2.5<br> - Fatal error in line 36 of file trigger_error.php, PHP 4.0.2 (Linux)<br> -Aborting...<br> +FATAL [256] log(x) for x <= 0 is undefined, you used: scale = -2.5
+ Fatal error in line 36 of file trigger_error.php, PHP 4.0.2 (Linux)
+Aborting...
+]]>
@@ -507,8 +517,10 @@ Aborting...<br> For example: + diff --git a/functions/exec.xml b/functions/exec.xml index b836110f33..9097572b65 100644 --- a/functions/exec.xml +++ b/functions/exec.xml @@ -1,5 +1,5 @@ - + Program Execution functions Program Execution @@ -38,7 +38,9 @@ + @@ -76,10 +78,12 @@ system("ls ".escapeshellarg($dir)); + diff --git a/functions/fbsql.xml b/functions/fbsql.xml index 1a825f6039..d9d2db7788 100644 --- a/functions/fbsql.xml +++ b/functions/fbsql.xml @@ -1,5 +1,5 @@ - + FrontBase Functions FrontBase @@ -194,12 +194,14 @@ <function>fbsql_close</function> example -<?php + +]]> @@ -295,14 +297,16 @@ <function>fbsql_connect</function> example -<?php + +]]> @@ -339,7 +343,8 @@ <function>fbsql_create_db</function> example -<?php + +]]> @@ -385,7 +391,8 @@ <function>fbsql_create_blob</function> example -<?php + +]]> @@ -438,7 +446,8 @@ <function>fbsql_create_clob</function> example -<?php + +]]> @@ -538,7 +548,8 @@ <function>fbsql_data_seek</function> example -<?php +\n", $row->last_name, $row->first_name); + printf("%s %s
\n", $row->last_name, $row->first_name); } fbsql_free_result ($result); -?> +?> +]]>
@@ -751,14 +763,16 @@ sure you check the value before calling another fbsql function. -<?php +"; +echo fbsql_errno().": ".fbsql_error()."
"; fbsql_select_db("nonexistentdb"); -echo fbsql_errno().": ".fbsql_error()."<BR>"; +echo fbsql_errno().": ".fbsql_error()."
"; $conn = fbsql_query("SELECT * FROM nonexistenttable;"); -echo fbsql_errno().": ".fbsql_error()."<BR>"; -?> +echo fbsql_errno().": ".fbsql_error()."
"; +?> +]]>
@@ -803,14 +817,16 @@ echo fbsql_errno().": ".fbsql_error()."<BR>"; sure you check the value before calling another fbsql function. -<?php +"; +echo fbsql_errno().": ".fbsql_error()."
"; fbsql_select_db("nonexistentdb"); -echo fbsql_errno().": ".fbsql_error()."<BR>"; +echo fbsql_errno().": ".fbsql_error()."
"; $conn = fbsql_query("SELECT * FROM nonexistenttable;"); -echo fbsql_errno().": ".fbsql_error()."<BR>"; -?> +echo fbsql_errno().": ".fbsql_error()."
"; +?> +]]>
@@ -859,7 +875,9 @@ echo fbsql_errno().": ".fbsql_error()."<BR>"; make an alias for the column. +
@@ -883,17 +901,19 @@ select t1.f1 as foo t2.f1 as bar from t1, t2 <function>fbsql_fetch_array</function> example -<?php +\n"; - echo "user_id: ".$row[0]."<br>\n"; - echo "fullname: ".$row["fullname"]."<br>\n"; - echo "fullname: ".$row[1]."<br>\n"; + echo "user_id: ".$row["user_id"]."
\n"; + echo "user_id: ".$row[0]."
\n"; + echo "fullname: ".$row["fullname"]."
\n"; + echo "fullname: ".$row[1]."
\n"; } fbsql_free_result ($result); -?> +?> +]]>
@@ -945,7 +965,8 @@ fbsql_free_result ($result); <function>fbsql_fetch_assoc</function> example -<?php + +]]> @@ -1021,30 +1043,32 @@ fbsql_free_result ($result); <function>fbsql_fetch_field</function> example -<?php +\n"; +while ($i < fbsql_num_fields ($result)) { + echo "Information for column $i:
\n"; $meta = fbsql_fetch_field ($result); if (!$meta) { - echo "No information available<BR>\n"; + echo "No information available
\n"; } - echo "<PRE> + echo "

 max_length:   $meta->max_length
 name:         $meta->name
 not_null:     $meta->not_null
 table:        $meta->table
 type:         $meta->type
-</PRE>";
+
"; $i++; } fbsql_free_result ($result); -?> +?> +]]>
@@ -1131,7 +1155,8 @@ fbsql_free_result ($result); <function>fbsql_fetch_object</function> example -<?php +fullname; } fbsql_free_result ($result); -?> +?> +]]> @@ -1248,6 +1274,7 @@ fbsql_free_result ($result); <function>fbsql_field_name</function> example + @@ -1264,8 +1292,10 @@ echo fbsql_field_name($res, 2); The above example would produce the following output: + @@ -1372,7 +1402,8 @@ password <function>fbsql_field_type</function> example -<?php +"; -echo "The table has the following fields <BR>"; -while ($i < $fields) { +echo "Your '".$table."' table has ".$fields." fields and ".$rows." records
"; +echo "The table has the following fields
"; +while ($i < $fields) { $type = fbsql_field_type ($result, $i); $name = fbsql_field_name ($result, $i); $len = fbsql_field_len ($result, $i); $flags = fbsql_field_flags ($result, $i); - echo $type." ".$name." ".$len." ".$flags."<BR>"; + echo $type." ".$name." ".$len." ".$flags."
"; $i++; } fbsql_close(); -?> +?> +]]>
@@ -1498,12 +1530,14 @@ fbsql_close(); <function>fbsql_list_dbs</function> example +Database . "\n"; } +]]> @@ -1511,10 +1545,12 @@ while ($row = fbsql_fetch_object($db_list)) { The above example would produce the following output: + @@ -1566,14 +1602,16 @@ database3 <function>fbsql_list_fields</function> example + @@ -1581,10 +1619,12 @@ for ($i = 0; $i < $columns; $i++) { The above example would produce the following output: + @@ -1649,7 +1689,8 @@ field3 <function>fbsql_next_result</function> example -<?php + +]]> @@ -1714,7 +1756,8 @@ field3 <function>fbsql_num_rows</function> example -<?php + +]]> @@ -1840,10 +1884,12 @@ echo "$num_rows Rows\n"; <function>fbsql_query</function> example -<?php + +]]> @@ -1855,10 +1901,12 @@ $result = fbsql_query ("SELECT * WHERE 1=1") <function>fbsql_query</function> example -<?php + +]]> @@ -1929,7 +1977,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") <function>fbsql_read_blob</function> example -<?php + +]]> @@ -1991,7 +2041,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") <function>fbsql_read_clob</function> example -<?php + +]]> @@ -2293,16 +2345,18 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl") <function>fbsql_tablename</function> example -<?php +"; + echo $tb_names[$i] . "
"; $i++; } -?> +?> +]]>
diff --git a/functions/fdf.xml b/functions/fdf.xml index 014c6f9e7b..189a75c867 100644 --- a/functions/fdf.xml +++ b/functions/fdf.xml @@ -1,5 +1,5 @@ - + Forms Data Format functions FDF @@ -58,7 +58,8 @@ Evaluating a FDF document -<?php +$volume</B>'<BR>"; +echo "The volume field has the value '$volume'
"; $date = fdf_get_value($fdf, "date"); -echo "The date field has the value '<B>$date</B>'<BR>"; +echo "The date field has the value '$date'
"; $comment = fdf_get_value($fdf, "comment"); -echo "The comment field has the value '<B>$comment</B>'<BR>"; +echo "The comment field has the value '$comment'
"; if(fdf_get_value($fdf, "show_publisher") == "On") { $publisher = fdf_get_value($fdf, "publisher"); - echo "The publisher field has the value '<B>$publisher</B>'<BR>"; + echo "The publisher field has the value '$publisher'
"; } else - echo "Publisher shall not be shown.<BR>"; + echo "Publisher shall not be shown.
"; if(fdf_get_value($fdf, "show_preparer") == "On") { $preparer = fdf_get_value($fdf, "preparer"); - echo "The preparer field has the value '<B>$preparer</B>'<BR>"; + echo "The preparer field has the value '$preparer'
"; } else - echo "Preparer shall not be shown.<BR>"; + echo "Preparer shall not be shown.
"; fdf_close($fdf); -?> +?> +]]>
@@ -122,7 +124,8 @@ fdf_close($fdf); Accessing the form data -<?php + +]]>
@@ -185,7 +189,8 @@ fdf_close($fdf); Populating a PDF document -<?php + +]]> diff --git a/functions/filesystem.xml b/functions/filesystem.xml index 844f84b136..2efecff4aa 100644 --- a/functions/filesystem.xml +++ b/functions/filesystem.xml @@ -1,5 +1,5 @@ - + Filesystem functions Filesystem @@ -36,9 +36,11 @@ <function>basename</function> example + @@ -115,9 +117,11 @@ $file = basename ($path,".php"); // $file is set to "index" you need to prefix mode with a zero (0): + @@ -238,9 +242,11 @@ chmod ("/somedir/somefile", 0755); // octal; correct value of mode <function>copy</function> example +\n"); + print ("failed to copy $file...
\n"); } +]]>
@@ -300,8 +306,10 @@ if (!copy($file, $file.'.bak')) { <function>dirname</function> example + @@ -333,8 +341,10 @@ $file = dirname ($path); // $file is set to "/etc" <function>disk_free_space</function> example + @@ -384,8 +394,10 @@ $df = disk_free_space("/"); // $df contains the number of bytes <function>disk_total_space</function> example + @@ -554,17 +566,19 @@ $df = disk_total_space("/"); // $df contains the total number of contents of a CSV file + $num fields in line $row:
"; $row++; - for ($c=0; $c<$num; $c++) { - print $data[$c] . "<br>"; + for ($c=0; $c < $num; $c++) { + print $data[$c] . "
"; } } fclose ($fp); +]]>
@@ -611,12 +625,14 @@ fclose ($fp); Reading a file line by line + @@ -703,16 +719,18 @@ fclose ($fd); -<?php +Line $line_num:; " . htmlspecialchars ($line) . "
\n"; } // get a web page into a string $fcontents = join ('', file ('http://www.php.net')); -?> +?> +]]>
@@ -1266,10 +1284,12 @@ $fcontents = join ('', file ('http://www.php.net')); <function>fopen</function> example + @@ -1284,7 +1304,9 @@ $fp = fopen ("ftp://user:password@example.com/", "w"); used in the path to the file, or use forward slashes. + @@ -1392,11 +1414,13 @@ $fp = fopen ("c:\\data\\info.txt", "r"); + @@ -1410,10 +1434,12 @@ fclose ($fd); + @@ -1457,21 +1483,25 @@ fclose ($fd); <function>fscanf</function> Example + users.txt + @@ -1730,12 +1760,14 @@ luigi florist it <function>set_file_buffer</function> example + @@ -2101,7 +2133,9 @@ if($fp){ can change using umask. + @@ -2216,6 +2250,7 @@ mkdir ("/path/to/my/dir", 0700); Contents of sample.ini + @@ -2252,6 +2288,7 @@ print_r($ini_array); Would produce: + 1 @@ -2272,6 +2309,7 @@ Array ) ) +]]> @@ -2302,7 +2340,8 @@ Array <function>pathinfo</function> Example -<?php + +]]> @@ -2318,9 +2358,11 @@ echo $path_parts["extension"] . "\n"; Would produce: + @@ -2395,7 +2437,9 @@ html + @@ -2699,7 +2743,9 @@ $fp = popen ("/bin/ls", "r"); <function>realpath</function> example + @@ -2773,7 +2819,9 @@ $real_path = realpath ("../../index.php"); <function>tempnam</function> example + @@ -2854,12 +2902,14 @@ $tmpfname = tempnam ("/tmp", "FOO"); <function>touch</function> example + diff --git a/functions/ftp.xml b/functions/ftp.xml index 532b5c6047..d98567c9d6 100644 --- a/functions/ftp.xml +++ b/functions/ftp.xml @@ -1,5 +1,5 @@ - + FTP functions FTP @@ -26,7 +26,8 @@ <function>ftp</function> example -<?php + +]]> @@ -401,7 +403,9 @@ ftp_quit($conn_id); <function>ftp_put</function> example + diff --git a/functions/funchand.xml b/functions/funchand.xml index 8166f7a046..44b50d449d 100755 --- a/functions/funchand.xml +++ b/functions/funchand.xml @@ -1,5 +1,5 @@ - + Function Handling functions Functions @@ -40,6 +40,7 @@ For example: + @@ -103,11 +105,13 @@ call_user_func_array ('debug', array("HTTP_POST_VARS", $HTTP_POST_VARS)); following: + @@ -153,12 +157,14 @@ call_user_func ('barber', "shave"); Creating an anonymous function with create_function + Or, perhaps to have general handler function that can apply a set @@ -169,15 +175,16 @@ echo $newfunc(2,M_E)."\n"; create_function +=0) {return "b*a^2 = ".$b*sqrt($a);} else {return false;}'; $f2 = "return \"min(b^2+a, a^2,b) = \".min(\$a*\$a+\$b,\$b*\$b+\$a);"; -$f3 = 'if ($a > 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return false;}'; +$f3 = 'if ($a > 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return false;}'; $farr = array( create_function('$x,$y', 'return "some trig: ".(sin($x) + $x*cos($y));'), create_function('$x,$y', 'return "a hypotenuse: ".sqrt($x*$x + $y*$y);'), @@ -199,11 +206,13 @@ $garr = array( ); echo "\nUsing the second array of anonymous functions\n"; process("Twas brilling and the slithy toves", "Twas the night", $garr); +]]> and when you run the code above, the output will be: + But perhaps the most common use for of lambda-style (anonymous) functions @@ -225,16 +235,17 @@ similar(a,b) = 11(45.833333333333%) Using anonymous functions as callback functions + the mango +// [1] => a mango +// [2] => that mango +// [3] => this mango // ) // an array of strings ordered from shorter to longer @@ -243,10 +254,10 @@ print_r($sv); // outputs: // Array // ( -// [0] => small -// [1] => larger -// [2] => a big string -// [3] => it is a string thing +// [0] => small +// [1] => larger +// [2] => a big string +// [3] => it is a string thing // ) // sort it from longer to shorter @@ -255,11 +266,12 @@ print_r($sv); // outputs: // Array // ( -// [0] => it is a string thing -// [1] => a big string -// [2] => larger -// [3] => small +// [0] => it is a string thing +// [1] => a big string +// [2] => larger +// [3] => small // ) +]]> @@ -294,17 +306,19 @@ print_r($sv); -<?php +\n"; + if ($numargs >= 2) { + echo "Second argument is: " . func_get_arg (1) . "
\n"; } } foo (1, 2, 3); -?> +?> +]]>
@@ -346,21 +360,23 @@ foo (1, 2, 3); -<?php +\n"; + if ($numargs >= 2) { + echo "Second argument is: " . func_get_arg (1) . "
\n"; } $arg_list = func_get_args(); - for ($i = 0; $i < $numargs; $i++) { - echo "Argument $i is: " . $arg_list[$i] . "<br>\n"; + for ($i = 0; $i < $numargs; $i++) { + echo "Argument $i is: " . $arg_list[$i] . "
\n"; } } foo (1, 2, 3); -?> +?> +]]>
@@ -402,14 +418,16 @@ foo (1, 2, 3); -<?php + +]]> @@ -448,11 +466,13 @@ foo (1, 2, 3); // Prints 'Number of arguments: 3' function name was found, &false; otherwise. +\n"; } else { - echo "IMAP functions are not available.<br>\n"; + echo "IMAP functions are not available.
\n"; } +]]>
Note that a function name may exist, even if the function itself @@ -487,8 +507,9 @@ if (function_exists('imap_open')) { $arr["user"] (see example below). +$id$data\n"; } $arr = get_defined_functions(); @@ -503,26 +524,27 @@ print_r($arr); Array ( - [internal] => Array + [internal] => Array ( - [0] => zend_version - [1] => func_num_args - [2] => func_get_arg - [3] => func_get_args - [4] => strlen - [5] => strcmp - [6] => strncmp + [0] => zend_version + [1] => func_num_args + [2] => func_get_arg + [3] => func_get_args + [4] => strlen + [5] => strcmp + [6] => strncmp ... - [750] => bcscale - [751] => bccomp + [750] => bcscale + [751] => bccomp ) - [user] => Array + [user] => Array ( - [0] => myrow + [0] => myrow ) ) +]]> diff --git a/functions/gettext.xml b/functions/gettext.xml index 03e674c902..05e9c3692d 100644 --- a/functions/gettext.xml +++ b/functions/gettext.xml @@ -1,5 +1,5 @@ - + Gettext gettext @@ -96,7 +96,8 @@ <function>gettext</function>-check -<?php + +]]> diff --git a/functions/gmp.xml b/functions/gmp.xml index 8f537c6a83..d2b4b3af58 100644 --- a/functions/gmp.xml +++ b/functions/gmp.xml @@ -1,5 +1,5 @@ - + GMP functions GMP @@ -51,7 +51,8 @@ Factorial function using GMP -<?php + +]]> @@ -92,10 +94,12 @@ print gmp_strval (fact (1000)) . "\n"; Creating GMP number -<?php + +]]> @@ -164,10 +168,12 @@ print gmp_strval (fact (1000)) . "\n"; Converting a GMP number to a string + +]]> @@ -356,12 +362,14 @@ print gmp_strval (fact (1000)) . "\n"; Division of GMP numbers -<?php + +]]> diff --git a/functions/http.xml b/functions/http.xml index ca67e040f7..7babf9b493 100644 --- a/functions/http.xml +++ b/functions/http.xml @@ -1,5 +1,5 @@ - + HTTP functions HTTP @@ -39,8 +39,10 @@ multiple headers of the same type. For example: + @@ -51,10 +53,12 @@ header('WWW-Authenticate: NTLM',false); (302) status code to the browser. + @@ -69,9 +73,11 @@ exit; /* Make sure that code below does relative one yourself: + @@ -86,7 +92,9 @@ header("Location: http://".$HTTP_SERVER_VARS['HTTP_HOST'] make sure that your script generates the proper status code. + @@ -96,7 +104,9 @@ header("HTTP/1.0 404 Not Found"); Status header. + @@ -109,12 +119,14 @@ header("Status: 404 Not Found"); caching with + @@ -145,11 +157,13 @@ header("Pragma: no-cache"); // HTTP/1.0 when using a single PHP/HTML file. -<?php require("user_logging.inc") ?> + -<?php header ("Content-type: audio/x-pn-realaudio"); ?> + // Broken, Note the blank lines above +]]> @@ -172,11 +186,13 @@ header("Pragma: no-cache"); // HTTP/1.0 save dialog. -<?php + @@ -299,9 +315,11 @@ header("Content-Disposition: attachment; filename=downloaded.pdf"); <function>setcookie</function> send examples + @@ -310,10 +328,12 @@ setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1); <function>setcookie</function> delete examples + When deleting a cookie you should assure that the expiration date @@ -327,8 +347,10 @@ setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1); cookie in a script, simply use one of the following examples: + @@ -340,14 +362,16 @@ echo $HTTP_COOKIE_VARS["TestCookie"]; name: +\n"; + echo "$name == $value
\n"; } } +]]>
diff --git a/functions/hw.xml b/functions/hw.xml index cfece32f40..a52e9b69ff 100644 --- a/functions/hw.xml +++ b/functions/hw.xml @@ -1,5 +1,5 @@ - + Hyperwave functions Hyperwave @@ -282,9 +282,13 @@ http://your.hostname/name_of_object would return the object. The rewriting rule is quite easy: - + + + +]]> + + Now every URL relates to an object in the Hyperwave server. This causes a simple to solve problem. There is no way to execute a @@ -292,9 +296,13 @@ RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$1 [L] script. This can be fixed with another rewriting rule like the following: - + + + +]]> + + This will reserve the directory /usr/local/apache/htdocs/hw for additional scripts and other files. Just make sure this rule is @@ -305,9 +313,13 @@ RewriteRule ^/hw/(.*) /usr/local/apache/htdocs/hw/$1 [L] them all in one directory. Finally, don't forget to turn on the rewriting engine with - + + + +]]> + + My experiences have shown that you will need the following scripts: @@ -1707,11 +1719,13 @@ RewriteEngine on modifying an attribute + "books"); $addarr = array("Name" => "articles"); $hw_modifyobject($connect, $objid, $remarr, $addarr); +]]> In order to delete/add a name=value pair from/to the object record just @@ -1721,11 +1735,13 @@ RewriteEngine on adding a completely new attribute + 0); $addarr = array("Name" => "articles"); $hw_modifyobject($connect, $objid, $remarr, $addarr); +]]> @@ -1742,18 +1758,22 @@ RewriteEngine on modifying Title attribute + "en:Books"); $addarr = array("Title" => "en:Articles"); $hw_modifyobject($connect, $objid, $remarr, $addarr); +]]> or modifying Title attribute + array("en" => "Books")); $addarr = array("Title" => array("en" => "Articles", "ge"=>"Artikel")); $hw_modifyobject($connect, $objid, $remarr, $addarr); +]]> This removes the english title 'Books' and adds the english title @@ -1761,9 +1781,11 @@ RewriteEngine on removing attribute + ""); $addarr = array("Title" => "en:Articles"); $hw_modifyobject($connect, $objid, $remarr, $addarr); +]]> diff --git a/functions/ibase.xml b/functions/ibase.xml index 920caafbc7..c1a5cc3227 100644 --- a/functions/ibase.xml +++ b/functions/ibase.xml @@ -1,5 +1,5 @@ - + InterBase functions InterBase @@ -21,7 +21,9 @@ php.ini the following directive: + @@ -87,7 +89,8 @@ magic_quotes_sybase = On <function>ibase_connect</function> example -<?php + +]]> @@ -303,7 +307,8 @@ magic_quotes_sybase = On ibase_execute. -<php + +]]> @@ -343,6 +349,7 @@ magic_quotes_sybase = On relation, length, type. + @@ -434,7 +442,8 @@ for ($i=0 ; $i < $coln ; $i++) { some parameters changing. -<?php + 'Eric', 5 => 'Filip', @@ -447,6 +456,7 @@ for ($i=0 ; $i < $coln ; $i++) { ibase_execute($query, $bar, $baz); } ?> +]]> @@ -577,11 +587,13 @@ for ($i=0 ; $i < $coln ; $i++) { defaults to IBASE_TIMESTAMP for backwards compatibility. -<?php + +]]> @@ -627,7 +639,8 @@ for ($i=0 ; $i < $coln ; $i++) { set. -<?php + +]]> diff --git a/functions/iconv.xml b/functions/iconv.xml index 9118010286..e73930afaa 100644 --- a/functions/iconv.xml +++ b/functions/iconv.xml @@ -1,5 +1,5 @@ - + iconv functions iconv @@ -49,7 +49,9 @@ <function>iconv</function> example: + @@ -111,8 +113,10 @@ echo iconv("ISO-8859-1","UTF-8","This is test."); <function>iconv_set_encoding</function> example: + @@ -159,7 +163,9 @@ iconv_set_encoding("output_encoding", "ISO-8859-1"); <function>ob_iconv_handler</function> example: + diff --git a/functions/ifx.xml b/functions/ifx.xml index a99acecd26..0ddd122940 100644 --- a/functions/ifx.xml +++ b/functions/ifx.xml @@ -1,5 +1,5 @@ - + Informix functions Informix @@ -212,8 +212,10 @@ ifx_close. Connect to a Informix database - + + @@ -310,10 +312,12 @@ $conn_id = ifx_connect ("mydb@ol_srv1", "imyself", "mypassword"); ifx_pconnect. Closing a Informix connection - + + @@ -401,22 +405,25 @@ ifx_close($conn_id); Show all rows of the "orders" table as a html table - + +%s<br>\n", ifx_error()); + printf("Can't select orders : %s\n
%s
\n", ifx_error()); ifx_errormsg(); die; } ifx_htmltbl_result($res_id, "border=\"1\""); ifx_free_result($res_id); +]]>
Insert some values into the "catalog" table - - // create blob id's for a byte and text column + + @@ -618,8 +626,10 @@ ifx_free_result($res_id); See also: ifx_error - + +", ifx_errormsg(-201)); +]]> @@ -665,7 +675,8 @@ printf("%s\n<br>", ifx_errormsg(-201)); Informix affected rows - + + 1000) { - printf ("Too many rows in result set (%d)\n<br>", $rowcount); - die ("Please restrict your query<br>\n"); + printf ("Too many rows in result set (%d)\n
", $rowcount); + die ("Please restrict your query
\n"); } +]]>
@@ -719,7 +731,8 @@ if ($rowcount > 1000) { Retrieve Informix sqlca.sqlerrd[x] values - + +\n"; +echo "The serial value of the inserted row is : " . $serial_value
\n"; +]]>
@@ -785,7 +799,8 @@ echo "The serial value of the inserted row is : " . $serial_value<br>\n"; Informix fetch rows - + + 1000) { - printf ("Too many rows in result set (%d)\n<br>", $rowcount); - die ("Please restrict your query<br>\n"); + printf ("Too many rows in result set (%d)\n
", $rowcount); + die ("Please restrict your query
\n"); } if (! ifx_do ($rid)) { ... error ... @@ -805,10 +820,11 @@ while (is_array($row)) { $fieldvalue = $row[$fieldname]; printf ("%s = %s,", $fieldname, $fieldvalue); } - printf("\n<br>"); + printf("\n
"); $row = ifx_fetch_row ($rid, "NEXT"); } ifx_free_result ($rid); +]]>
@@ -842,7 +858,8 @@ ifx_free_result ($rid); Informix results as HTML table - + + 1000) { - printf ("Too many rows in result set (%d)\n<br>", $rowcount); - die ("Please restrict your query<br>\n"); + printf ("Too many rows in result set (%d)\n
", $rowcount); + die ("Please restrict your query
\n"); } if (! ifx_do($rid) { ... error ... @@ -860,6 +877,7 @@ if (! ifx_do($rid) { ifx_htmltbl_result ($rid, "border=\"2\""); ifx_free_result($rid); +]]>
@@ -885,16 +903,18 @@ ifx_free_result($rid); Fielnames and SQL fieldtypes - + + @@ -926,16 +946,18 @@ for ($i = 0; $i < count($types); $i++) { Informix SQL fieldproperties - + + diff --git a/functions/image.xml b/functions/image.xml index e9b61e3c13..fe380db61d 100644 --- a/functions/image.xml +++ b/functions/image.xml @@ -1,5 +1,5 @@ - + Image functions Image @@ -69,8 +69,10 @@ GetImageSize (file) -<?php $size = GetImageSize ("img/flag.jpg"); ?> -<IMG SRC="img/flag.jpg" <?php echo $size[3]; ?> + + +]]> @@ -78,7 +80,9 @@ GetImageSize (URL) -<?php $size = GetImageSize ("http://www.php.net/gifs/logo.gif"); ?> + +]]> @@ -107,13 +111,15 @@ GetImageSize returning IPTC -<?php + +]]> @@ -447,8 +453,10 @@ by im. + @@ -483,8 +491,10 @@ $black = ImageColorAllocate ($im, 0, 0, 0); ImageColorAllocate function. + @@ -1103,7 +1113,8 @@ ImageColorDeAllocate($im, $white); Creating a new GD image stream and outputting an image. -<?php + +]]> @@ -1210,6 +1222,7 @@ ImagePng ($im); vic@zymsys.com) + @@ -1263,6 +1277,7 @@ function LoadGif ($imgname) { vic@zymsys.com ) + @@ -1309,6 +1325,7 @@ function LoadJpeg ($imgname) { vic@zymsys.com) + @@ -1355,6 +1373,7 @@ function LoadPNG ($imgname) { vic@zymsys.com) + @@ -1689,7 +1709,8 @@ function LoadWBMP ($imgname) { ImageGIF($im); by the more flexible sequence: -<?php + +]]> @@ -1721,12 +1743,15 @@ function LoadWBMP ($imgname) { the presence of the various supported image formats: + + ... etc. +]]> + @@ -1763,10 +1788,12 @@ elseif (ImageTypes() & IMG_JPG) { filename it outputs the image to the file. -<?php + +]]> @@ -2284,7 +2311,8 @@ ImagePng($im); -<?php + +]]> @@ -2603,7 +2632,8 @@ ImageDestroy ($im); ImageSetStyle -<?php + +]]> @@ -2993,7 +3024,8 @@ ImageDestroy ($im); ImageTTFText -<?php + +]]> @@ -3039,11 +3072,13 @@ ImageDestroy ($im); ImageTypes -<?php + +]]> @@ -3153,10 +3188,11 @@ if (ImageTypes() & IMG_PNG) { read_exif_data -<?php +\n"; + echo "$k: $v
\n"; } ?> @@ -3181,6 +3217,7 @@ FocusDistance: 16.66m RawFocusDistance: 16.659999847412 Orientation: 1 ExifVersion: 0200 +]]>
diff --git a/functions/imap.xml b/functions/imap.xml index d22d9964f3..1cdc09862d 100644 --- a/functions/imap.xml +++ b/functions/imap.xml @@ -1,5 +1,5 @@ - + IMAP, POP3 and NNTP functions IMAP @@ -180,6 +180,7 @@ <function>imap_append</function> example +Nmsgs."\n"; imap_close($stream); +]]> @@ -454,6 +456,7 @@ ST_UID The sequence argument contains UIDs instead of <function>imap_createmailbox</function> example +\n"; +echo "Newname will be '$name1'
\n"; # we will now create a new mailbox "phptestbox" in your inbox folder, # check its status after creation and finaly remove it to restore @@ -470,33 +473,34 @@ echo "Newname will be '$name1'<br>\n"; if(@imap_createmailbox($mbox,imap_utf7_encode("{your.imap.host}INBOX.$newname"))) { $status = @imap_status($mbox,"{your.imap.host}INBOX.$newname",SA_ALL); if($status) { - print("your new mailbox '$name1' has the following status:<br>\n"); - print("Messages: ". $status->messages )."<br>\n"; - print("Recent: ". $status->recent )."<br>\n"; - print("Unseen: ". $status->unseen )."<br>\n"; - print("UIDnext: ". $status->uidnext )."<br>\n"; - print("UIDvalidity:". $status->uidvalidity)."<br>\n"; + print("your new mailbox '$name1' has the following status:
\n"); + print("Messages: ". $status->messages )."
\n"; + print("Recent: ". $status->recent )."
\n"; + print("Unseen: ". $status->unseen )."
\n"; + print("UIDnext: ". $status->uidnext )."
\n"; + print("UIDvalidity:". $status->uidvalidity)."
\n"; if(imap_renamemailbox($mbox,"{your.imap.host}INBOX.$newname","{your.imap.host}INBOX.$name2")) { - echo "renamed new mailbox from '$name1' to '$name2'<br>\n"; + echo "renamed new mailbox from '$name1' to '$name2'
\n"; $newname=$name2; } else { - print "imap_renamemailbox on new mailbox failed: ".imap_last_error()."<br>\n"; + print "imap_renamemailbox on new mailbox failed: ".imap_last_error()."
\n"; } } else { - print "imap_status on new mailbox failed: ".imap_last_error()."<br>\n"; + print "imap_status on new mailbox failed: ".imap_last_error()."
\n"; } if(@imap_deletemailbox($mbox,"{your.imap.host}INBOX.$newname")) { - print "new mailbox removed to restore initial state<br>\n"; + print "new mailbox removed to restore initial state
\n"; } else { - print "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n"; + print "imap_deletemailbox on new mailbox failed: ".implode("
\n",imap_errors())."
\n"; } } else { - print "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n"; + print "could not create new mailbox: ".implode("
\n",imap_errors())."
\n"; } imap_close($mbox); +]]>
@@ -541,18 +545,20 @@ imap_close($mbox); <function>imap_delete</function> Beispiel +Nmsgs . "<br>\n" ; +print "Messages before delete: " . $check->Nmsgs . "
\n" ; imap_delete ($mbox, 1); $check = imap_mailboxmsginfo ($mbox); -print "Messages after delete: " . $check->Nmsgs . "<br>\n" ; +print "Messages after delete: " . $check->Nmsgs . "
\n" ; imap_expunge ($mbox); $check = imap_mailboxmsginfo ($mbox); -print "Messages after expunge: " . $check->Nmsgs . "<br>\n" ; +print "Messages after expunge: " . $check->Nmsgs . "
\n" ; imap_close ($mbox); +]]>
@@ -744,6 +750,7 @@ imap_close ($mbox); <function>imap_fetch_overview</function> example + @@ -1072,6 +1080,7 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the <function>imap_get_quota</function> example + @@ -1170,6 +1180,7 @@ imap_close($mbox); <function>imap_getmailboxes</function> example +name).","; print "'".$val->delimiter."',"; - print $val->attributes."<br>\n"; + print $val->attributes."
\n"; } } else print "imap_getmailboxes failed: ".imap_last_error()."\n"; imap_close($mbox); +]]>
@@ -1442,6 +1454,7 @@ fetchsubject (subject line formatted to fit subjectlength <function>imap_listmailbox</function> example +\n"; + print imap_utf7_decode($val)."
\n"; } else print "imap_listmailbox failed: ".imap_last_error()."\n"; imap_close($mbox); +]]>
@@ -1544,7 +1558,8 @@ imap_close($mbox); <function>imap_mail_compose</function> example -<?php + +]]> @@ -1738,7 +1754,8 @@ echo nl2br(imap_mail_compose($envelope,$body)); <function>imap_mailboxmsginfo</function> example -<?php +Date ."<br>\n" ; - print "Driver: " . $check->Driver ."<br>\n" ; - print "Mailbox: " . $check->Mailbox ."<br>\n" ; - print "Messages: ". $check->Nmsgs ."<br>\n" ; - print "Recent: " . $check->Recent ."<br>\n" ; - print "Unread: " . $check->Unread ."<br>\n" ; - print "Deleted: " . $check->Deleted ."<br>\n" ; - print "Size: " . $check->Size ."<br>\n" ; + print "Date: " . $check->Date ."
\n" ; + print "Driver: " . $check->Driver ."
\n" ; + print "Mailbox: " . $check->Mailbox ."
\n" ; + print "Messages: ". $check->Nmsgs ."
\n" ; + print "Recent: " . $check->Recent ."
\n" ; + print "Unread: " . $check->Unread ."
\n" ; + print "Deleted: " . $check->Deleted ."
\n" ; + print "Size: " . $check->Size ."
\n" ; } else { - print "imap_check() failed: ".imap_last_error(). "<br>\n"; + print "imap_check() failed: ".imap_last_error(). "
\n"; } imap_close($mbox); -?> +?> +]]>
@@ -1794,14 +1812,15 @@ imap_close($mbox); <function>imap_mime_header_decode</function> example -$text="=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>"; +"; $elements=imap_mime_header_decode($text); -for($i=0;$i<count($elements);$i++) { +for($i=0;$icharset}\n"; echo "Text: {$elements[$i]->text}\n\n"; } - +]]> @@ -1954,33 +1973,43 @@ for($i=0;$i<count($elements);$i++) { local machine, do the following: + To connect to a POP3 server on port 110 on the local server, use: + To connect to an SSL IMAP or POP3 server, add /ssl after the protocol specification: + To connect to an SSL IMAP or POP3 server with a self-signed certificate, add /ssl/novalidate-cert after the protocol specification: + To connect to an NNTP server on port 119 on the local server, use: + To connect to a remote server replace "localhost" with the name @@ -1990,31 +2019,33 @@ $nntp = imap_open ("{localhost:119/nntp}comp.test", "", ""); <function>imap_open</function> example +<h1>Mailboxes</h1>\n"; +echo "

Mailboxes

\n"; $folders = imap_listmailbox ($mbox, "{your.imap.host:143}", "*"); if ($folders == false) { - echo "Call failed<br>\n"; + echo "Call failed
\n"; } else { while (list ($key, $val) = each ($folders)) { - echo $val."<br>\n"; + echo $val."
\n"; } } -echo "<p><h1>Headers in INBOX</h1>\n"; +echo "

Headers in INBOX

\n"; $headers = imap_headers ($mbox); if ($headers == false) { - echo "Call failed<br>\n"; + echo "Call failed
\n"; } else { while (list ($key,$val) = each ($headers)) { - echo $val."<br>\n"; + echo $val."
\n"; } } imap_close($mbox); +]]>
@@ -2215,17 +2246,19 @@ imap_close($mbox); <function>imap_rfc822_parse_adrlist</function> example -$address_string = "Hartmut Holzgraefe <hartmut@cvs.php.net>, postmaster@somedomain.net, root"; +, postmaster@somedomain.net, root"; $address_array = imap_rfc822_parse_adrlist($address_string,"somedomain.net"); if(! is_array($address_array)) die("somethings wrong\n"); reset($address_array); while(list($key,$val)=each($address_array)){ - print "mailbox : ".$val->mailbox."<br>\n"; - print "host : ".$val->host."<br>\n"; - print "personal: ".$val->personal."<br>\n"; - print "adl : ".$val->adl."<p>\n"; + print "mailbox : ".$val->mailbox."
\n"; + print "host : ".$val->host."
\n"; + print "personal: ".$val->personal."
\n"; + print "adl : ".$val->adl."

\n"; } +]]> @@ -2285,7 +2318,9 @@ while(list($key,$val)=each($address_array)){ <function>imap_rfc822_write_address</function> example + @@ -2527,6 +2562,7 @@ print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\ <function>imap_set_quota</function> example + @@ -2583,6 +2620,7 @@ ST_UID The sequence argument contains UIDs instead of <function>imap_setflag_full</function> example + @@ -2714,20 +2753,22 @@ SE_NOPREFETCH Don't prefetch searched messages. <function>imap_status</function> example +messages )."<br>\n"; - print("Recent: ". $status->recent )."<br>\n"; - print("Unseen: ". $status->unseen )."<br>\n"; - print("UIDnext: ". $status->uidnext )."<br>\n"; - print("UIDvalidity:". $status->uidvalidity)."<br>\n"; + print("Messages: ". $status->messages )."
\n"; + print("Recent: ". $status->recent )."
\n"; + print("Unseen: ". $status->unseen )."
\n"; + print("UIDnext: ". $status->uidnext )."
\n"; + print("UIDvalidity:". $status->uidvalidity)."
\n"; } else print "imap_status failed: ".imap_last_error()."\n"; imap_close($mbox); +]]>
diff --git a/functions/info.xml b/functions/info.xml index a061d6e3c4..0482f8a4d1 100644 --- a/functions/info.xml +++ b/functions/info.xml @@ -1,5 +1,5 @@ - + PHP options & information PHP options/info @@ -72,7 +72,8 @@ Handle a failed assertion with a custom handler -<?php +Assertion Failed: + File '$file'
+ Line '$line'
+ Code '$code'


"; } // Set up the callback @@ -91,7 +92,8 @@ assert_options (ASSERT_CALLBACK, 'my_assert_handler'); // Make an assertion that should fail assert ('mysql_query ("")'); -?> +?> +]]>
@@ -244,7 +246,9 @@ assert ('mysql_query ("")'); varname, or &false; on an error. + @@ -356,28 +360,32 @@ $ip = getenv ("REMOTE_ADDR"); // get the ip number of the user For example the line below + will print a list like: + 1 + [E_WARNING] => 2 + [E_PARSE] => 4 + [E_NOTICE] => 8 + [E_CORE_ERROR] => 16 + [E_CORE_WARNING] => 32 + [E_COMPILE_ERROR] => 64 + [E_COMPILE_WARNING] => 128 + [E_USER_ERROR] => 256 + [E_USER_WARNING] => 512 + [E_USER_NOTICE] => 1024 + [E_ALL] => 2047 + [TRUE] => 1 ) +]]> @@ -411,8 +419,10 @@ Array For example the lines below + will print a list of the functions in the modules @@ -479,7 +489,8 @@ print_r (get_extension_funcs ("gd")); <function>get_included_files</function> Example -<?php + +]]> will generate the following output: + @@ -549,27 +563,31 @@ test4.php For example the line below + will print a list like: + xml + [1] => wddx + [2] => standard + [3] => session + [4] => posix + [5] => pgsql + [6] => pcre + [7] => gd + [8] => ftp + [9] => db + [10] => Calendar + [11] => bcmath ) +]]> @@ -656,8 +674,10 @@ Array getlastmod() example + @@ -820,11 +840,13 @@ echo "Last modified: ".date ("F d Y H:i:s.", getlastmod()); Getrusage Example + See your system's man page on getrusage(2) for more details. @@ -1347,36 +1369,42 @@ echo $dat["ru_utime.tv_usec"]; # user time used (microseconds) use somewhere in your code: + And if you want to print the core developers and the documentation group, in a page of its own, you will use: -<?php + +]]> And if you feel like embedding all the credits in your page, then code like the one below will do it: -<html> - <head> - <title>My credits page</title> - </head> - <body> - <?php + + + My credits page + + + + + +]]> @@ -1509,8 +1537,10 @@ phpcredits(CREDITS_GROUP + CREDITS_DOCS + CREDITS_FULLPAGE); phpversion() example + @@ -1577,11 +1607,13 @@ echo "Current PHP version: ".phpversion(); <function>php_sapi_name</function> Example + @@ -1611,9 +1643,11 @@ else <function>php_uname</function> Example + @@ -1665,7 +1699,9 @@ if (substr(php_uname(), 0, 7) == "Windows") { Setting an Environment Variable + @@ -1790,13 +1826,13 @@ putenv ("UNIQID=$uniqid"); If you specify the third optional operator argument, you can test for a particular relationship. The possible - operators are: <, + operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, - !=, <>, + !=, <>, ne respectively. Using this argument, the function will return 1 if the realtionship is the one specified by the @@ -1806,12 +1842,14 @@ putenv ("UNIQID=$uniqid"); <function>version_compare</function> example + @@ -1860,8 +1898,10 @@ echo version_compare("4.0.6", "4.0.6", "eq"); <function>zend_version</function> example + diff --git a/functions/ingres_ii.xml b/functions/ingres_ii.xml index 47c108e4b6..1d54caeee3 100755 --- a/functions/ingres_ii.xml +++ b/functions/ingres_ii.xml @@ -1,5 +1,5 @@ - + Ingres II functions Ingres II @@ -93,12 +93,14 @@ <function>ingres_connect</function> example -<?php + +]]> @@ -106,12 +108,14 @@ ingres_connect example using default link -<?php + +]]> See also @@ -296,7 +300,8 @@ <function>ingres_query</function> example -<?php + +]]> @@ -687,10 +693,12 @@ while ($row = ingres_fetch_row()) { column or make an alias for the column. + @@ -709,7 +717,8 @@ $bar = $result["bar"]; <function>ingres_fetch_array</function> example -<?php + +]]> @@ -767,7 +777,8 @@ while ($row = ingres_fetch_array()) { <function>ingres_fetch_row</function> example -<?php + +]]> @@ -837,7 +849,8 @@ while ($row = ingres_fetch_row()) { <function>ingres_fetch_object</function> example -<?php +fullname; } ?> +]]> diff --git a/functions/ircg.xml b/functions/ircg.xml index b85caa3276..1d676cadc1 100644 --- a/functions/ircg.xml +++ b/functions/ircg.xml @@ -1,5 +1,5 @@ - + IRC Gateway Functions IRC Gateway @@ -108,11 +108,13 @@ <function>ircg_fetch_error_msg</function> example + diff --git a/functions/java.xml b/functions/java.xml index a239feb343..4ae60d1b5e 100644 --- a/functions/java.xml +++ b/functions/java.xml @@ -1,5 +1,5 @@ - + Java PHP / Java Integration @@ -20,44 +20,48 @@ Java Example -<?php +getProperty('java.version').'
'; + print 'Java vendor=' .$system->getProperty('java.vendor').'
'; + print 'OS='.$system->getProperty('os.name').' '. + $system->getProperty('os.version').' on '. + $system->getProperty('os.arch').'
'; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); - print $formatter->format(new Java('java.util.Date')); -?> + print $formatter->format(new Java('java.util.Date')); +?> +]]>
AWT Example -<?php +add('North', $button); + $frame->validate(); + $frame->pack(); + $frame->visible = True; $thread = new Java('java.lang.Thread'); - $thread->sleep(10000); + $thread->sleep(10000); - $frame->dispose(); -?> + $frame->dispose(); +?> +]]> @@ -200,9 +204,10 @@ Java exception handler +push(1); // This should succeed $result = $stack->pop(); @@ -210,13 +215,14 @@ if (!$ex) print "$result\n"; // This should fail (error suppressed by @) - $result = @$stack->pop(); + $result = @$stack->pop(); $ex = java_last_exception_get(); if ($ex) print $ex->toString(); // Clear last exception java_last_exception_clear(); ?> +]]> diff --git a/functions/ldap.xml b/functions/ldap.xml index dc91f2ecd0..d960a583f5 100644 --- a/functions/ldap.xml +++ b/functions/ldap.xml @@ -1,5 +1,5 @@ - + LDAP functions LDAP @@ -72,48 +72,50 @@ LDAP search example - -<?php + +LDAP query test</h3>"; +echo "

LDAP query test

"; echo "Connecting ..."; $ds=ldap_connect("localhost"); // must be a valid LDAP server! -echo "connect result is ".$ds."<p>"; +echo "connect result is ".$ds."

"; if ($ds) { echo "Binding ..."; $r=ldap_bind($ds); // this is an "anonymous" bind, typically // read-only access - echo "Bind result is ".$r."<p>"; + echo "Bind result is ".$r."

"; echo "Searching for (sn=S*) ..."; // Search surname entry $sr=ldap_search($ds,"o=My Company, c=US", "sn=S*"); - echo "Search result is ".$sr."<p>"; + echo "Search result is ".$sr."

"; - echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>"; + echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."

"; - echo "Getting entries ...<p>"; + echo "Getting entries ...

"; $info = ldap_get_entries($ds, $sr); - echo "Data for ".$info["count"]." items returned:<p>"; + echo "Data for ".$info["count"]." items returned:

"; - for ($i=0; $i<$info["count"]; $i++) { - echo "dn is: ". $info[$i]["dn"] ."<br>"; - echo "first cn entry is: ". $info[$i]["cn"][0] ."<br>"; - echo "first email entry is: ". $info[$i]["mail"][0] ."<p>"; + for ($i=0; $i<$info["count"]; $i++) { + echo "dn is: ". $info[$i]["dn"] ."
"; + echo "first cn entry is: ". $info[$i]["cn"][0] ."
"; + echo "first email entry is: ". $info[$i]["mail"][0] ."

"; } echo "Closing connection"; ldap_close($ds); } else { - echo "<h4>Unable to connect to LDAP server</h4>"; + echo "

Unable to connect to LDAP server

"; } ?> -
-
+]]> +
+ Using the PHP LDAP calls @@ -237,7 +239,8 @@ if ($ds) { Complete example with authenticated bind -<?php + +]]> @@ -349,7 +353,8 @@ if ($ds) { Complete example of password check -<?php + +]]> @@ -534,11 +540,13 @@ if ($ds) { Enumerating all LDAP error messages -<?php - for($i=0; $i<100; $i++) { - printf("Error $i: %s<br>\n", ldap_err2str($i)); +\n", ldap_err2str($i)); } ?> +]]> @@ -576,7 +584,8 @@ if ($ds) { Generating and catching an error -<?php +\n", ldap_errno($ld)); - printf("LDAP-Error: %s<br>\n", ldap_error($ld)); - die("Argh!<br>\n"); + printf("LDAP-Errno: %s
\n", ldap_errno($ld)); + printf("LDAP-Error: %s
\n", ldap_error($ld)); + die("Argh!
\n"); } $info = ldap_get_entries($ld, $res); -printf("%d matching entries.<br>\n", $info["count"]); +printf("%d matching entries.
\n", $info["count"]); ?> +]]>
@@ -812,6 +822,7 @@ return_value["attribute"][i] = ith value of the attribute Show the list of attributes held for a particular directory entry +"; +echo $attrs["count"]." attributes held for this entry:

"; -for ($i=0; $i<$attrs["count"]; $i++) - echo $attrs[$i]."<br>"; +for ($i=0; $i<$attrs["count"]; $i++) + echo $attrs[$i]."
"; +]]> @@ -944,11 +956,13 @@ return_value[i]["attribute"][j] = jth value of attribute in ith entry Check protocol version + @@ -1011,6 +1025,7 @@ return_value[i] = ith value of attribute List all values of the "mail" attribute for a directory entry +"; +echo $values["count"]." email addresses for this entry.

"; -for ($i=0; $i < $values["count"]; $i++) - echo $values[$i]."<br>"; +for ($i=0; $i < $values["count"]; $i++) + echo $values[$i]."
"; +]]> @@ -1127,6 +1143,7 @@ for ($i=0; $i < $values["count"]; $i++) Produce a list of all organizational units of an organization + @@ -1539,6 +1557,7 @@ for ($i=0; $i<$info["count"]; $i++) LDAP search +"; +print $info["count"]." entries returned

"; +]]> @@ -1626,16 +1646,19 @@ print $info["count"]." entries returned<p>"; Set protocol version + Set server controls + "1.2.752.58.10.1", "iscritical" => TRUE); @@ -1644,6 +1667,7 @@ $ctrl2 = array("oid" => "1.2.752.58.1.10", "value" => "magic"); // try to set both controls if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) echo "Failed to set server controls"; +]]> diff --git a/functions/mail.xml b/functions/mail.xml index 9b69182445..b8e2580f56 100644 --- a/functions/mail.xml +++ b/functions/mail.xml @@ -1,5 +1,5 @@ - + Mail functions Mail @@ -102,7 +102,9 @@ Sending mail. + @@ -124,10 +126,12 @@ mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3"); Sending mail with extra headers. + @@ -143,8 +147,10 @@ mail("nobody@example.com", "the subject", $message, Sending mail with extra headers and setting an additional command line parameter. + @@ -159,32 +165,33 @@ mail("nobody@example.com", "the subject", $message, Sending complex email. +" . ", " ; //note the comma +$to .= "Kelly "; /* subject */ $subject = "Birthday Reminders for August"; /* message */ $message = ' -<html> -<head> - <title>Birthday Reminders for August</title> -</head> -<body> -<p>Here are the birthdays upcoming in August!</p> -<table> - <tr> - <th>Person</th><th>Day</th><th>Month</th><th>Year</th> - </tr> - <tr> - <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> - <td>Sally</td><td>17th</td><td>August</td><td>1973</td> - </tr> -</table> -</body> -</html> + + + Birthday Reminders for August + + +

Here are the birthdays upcoming in August!

+ + + + + + + + +
PersonDayMonthYear
Joe3rdAugust1970Sally17thAugust1973
+ + '; /* To send HTML mail, you can set the Content-type header. */ @@ -192,13 +199,14 @@ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; /* additional headers */ -$headers .= "From: Birthday Reminder <birthday@example.com>\r\n"; +$headers .= "From: Birthday Reminder \r\n"; $headers .= "Cc: birthdayarchive@example.com\r\n"; $headers .= "Bcc: birthdaycheck@example.com\r\n"; /* and now mail it */ mail($to, $subject, $message, $headers); +]]>
@@ -233,10 +241,12 @@ mail($to, $subject, $message, $headers); Calculating the hash and subscribing a user +query($query); // using PHPLIB db interface +]]> diff --git a/functions/math.xml b/functions/math.xml index d6c50dbf7e..b1303b3057 100644 --- a/functions/math.xml +++ b/functions/math.xml @@ -1,5 +1,5 @@ - + Mathematical Functions Math @@ -354,7 +354,9 @@ <function>base_convert</function> + @@ -661,6 +663,7 @@ $binary = base_convert ($hexadecimal, 16, 2); <function>hexdec</function> example + @@ -899,6 +903,7 @@ var_dump(hexdec("a0")); seed. + @@ -1000,7 +1006,8 @@ $randval = mt_rand(); thousand separator. This is achieved with this line : -<?php + +]]> @@ -1077,10 +1085,10 @@ $randval = mt_rand(); - + @@ -1249,6 +1257,7 @@ echo pow(-1, 5.5); // error + @@ -1356,6 +1366,7 @@ $foo = round(1241757, -3); // $foo == 1242000 seed. + diff --git a/functions/mbstring.xml b/functions/mbstring.xml index f428a04065..b3ed49b105 100644 --- a/functions/mbstring.xml +++ b/functions/mbstring.xml @@ -1,5 +1,5 @@ - + Multi-Byte String Functions @@ -67,13 +67,14 @@ PHP and does NOT work with PHP. - + @@ -166,9 +167,10 @@ JIS, SJIS Disable HTTP input conversion in php.ini - + @@ -206,7 +208,7 @@ mbstring.http_input = pass <literal>php.ini</literal> setting example - + @@ -221,8 +224,8 @@ output_handler = mb_output_handler Script example - -<?php + +]]> @@ -360,7 +364,7 @@ ob_start('mb_output_handler'); <literal>php.ini</literal> setting example - + @@ -392,7 +397,7 @@ mbstring.substitute_character = long ; Long Example: U+3000,JIS+7E7E <literal>php.ini</literal> setting for <literal>EUC-JP</literal> users - + @@ -417,7 +423,7 @@ mbstring.substitute_character = none <literal>php.ini</literal> setting for <literal>SJIS</literal> users - + @@ -662,11 +669,13 @@ mbstring.substitute_character = none <function>mb_internal_encoding</function> example + @@ -818,12 +827,14 @@ echo mb_internal_encoding(); Useless detect order example + @@ -832,6 +843,7 @@ detect_order = UTF-8, ASCII, UTF-7 <function>mb_detect_order</function> examples + @@ -910,6 +923,7 @@ echo implode(", ", mb_detect_order()); <function>mb_substitute_character</function> example + @@ -981,8 +996,10 @@ echo mb_substitute_character(); <function>mb_output_handler</function> example + @@ -1023,10 +1040,12 @@ ob_start("mb_output_handler"); <function>mb_preferred_mime_string</function> example + @@ -1309,6 +1328,7 @@ header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc)) + @@ -1375,7 +1396,9 @@ header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc)) <function>mb_strimwidth</function> example +"); +]]> @@ -1422,6 +1445,7 @@ $str = mb_strimwidth($str, 0, 40, "..>"); <function>mb_convert_encoding</function> example + @@ -1478,6 +1502,7 @@ $str = mb_convert_encoding($str, "EUC-JP", "auto"); <function>mb_detect_encoding</function> example + @@ -1538,6 +1564,7 @@ echo mb_detect_encoding($str, $ary); + @@ -1565,12 +1593,14 @@ echo mb_detect_encoding($str, $ary); <function>mb_convert_kana</function> example + @@ -1623,11 +1653,13 @@ $str = mb_convert_kana($str, "KVa"); <function>mb_convert_kana</function> example +"; +$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">"; echo $addr; +]]> @@ -1710,9 +1742,11 @@ echo $addr; <function>mb_convert_variables</function> example + @@ -1756,6 +1790,7 @@ $inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $pos <parameter>convmap</parameter> example + @@ -1773,6 +1809,7 @@ $convmap = array ( mb_encode_numericentity example + @@ -1837,6 +1875,7 @@ $str = mb_encode_numericentity($str, $convmap, "sjis-win"); <parameter>convmap</parameter> example +