mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
started to wrap up all <programlisting> 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
This commit is contained in:
parent
f748593f15
commit
4a6f22f50a
41 changed files with 1506 additions and 723 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<reference id="ref.apache">
|
||||
<title>Apache-specific Functions</title>
|
||||
<titleabbrev>Apache</titleabbrev>
|
||||
|
@ -173,10 +173,12 @@
|
|||
<example>
|
||||
<title><function>getallheaders</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$headers = getallheaders();
|
||||
while (list ($header, $value) = each ($headers)) {
|
||||
echo "$header: $value<br>\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<!-- $Revision: 1.18 $ -->
|
||||
<reference id="ref.aspell">
|
||||
<title>Aspell functions [deprecated]</title>
|
||||
<titleabbrev>Aspell</titleabbrev>
|
||||
|
@ -50,7 +50,9 @@
|
|||
<example>
|
||||
<title><function>aspell_new</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$aspell_link = aspell_new("english");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -79,6 +81,7 @@ $aspell_link = aspell_new("english");
|
|||
<example>
|
||||
<title><function>aspell_check</function></title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$aspell_link = aspell_new("english");
|
||||
|
||||
if (aspell_check($aspell_link, "testt")) {
|
||||
|
@ -86,6 +89,7 @@ if (aspell_check($aspell_link, "testt")) {
|
|||
} else {
|
||||
echo "Sorry, wrong spelling";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -117,6 +121,7 @@ if (aspell_check($aspell_link, "testt")) {
|
|||
<example>
|
||||
<title><function>aspell_check_raw</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$aspell_link = aspell_new("english");
|
||||
|
||||
if (aspell_check_raw($aspell_link, "test")) {
|
||||
|
@ -124,6 +129,7 @@ if (aspell_check_raw($aspell_link, "test")) {
|
|||
} else {
|
||||
echo "Sorry, wrong spelling";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -152,15 +158,17 @@ if (aspell_check_raw($aspell_link, "test")) {
|
|||
<example>
|
||||
<title><function>aspell_suggest</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$aspell_link = aspell_new("english");
|
||||
|
||||
if (!aspell_check($aspell_link, "test")) {
|
||||
$suggestions = aspell_suggest($aspell_link, "test");
|
||||
|
||||
foreach ($suggestions as $suggestion) {
|
||||
echo "Possible spelling: $suggestion<br>\n";
|
||||
echo "Possible spelling: $suggestion<br>\n";
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<reference id="ref.bzip2">
|
||||
<title>Bzip2 Compression Functions</title>
|
||||
<titleabbrev>Bzip2</titleabbrev>
|
||||
|
@ -25,7 +25,8 @@
|
|||
<example>
|
||||
<title>Small bzip2 Example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$filename = "/tmp/testfile.bz2";
|
||||
$str = "This is a test string.\n";
|
||||
|
@ -51,6 +52,7 @@ print bzread($bz);
|
|||
bzclose($bz);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
|
@ -129,11 +131,14 @@ bzclose($bz);
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzcompress</function> Example</title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$str = "sample data";
|
||||
$bzstr = bzcompress($str, 9);
|
||||
print( $bzstr );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -173,19 +178,22 @@ print( $bzstr );
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzdecompress</function></title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$start_str = "This is not an honest face?";
|
||||
$bzstr = bzcompress($start_str);
|
||||
|
||||
print( "Compressed String: " );
|
||||
print( $bzstr );
|
||||
print( "\n<br>n" );
|
||||
print( "\n<br>\n" );
|
||||
|
||||
$str = bzdecompress($bzstr);
|
||||
print( "Decompressed String: " );
|
||||
print( $str );
|
||||
print( "\n<br>n" );
|
||||
print( "\n<br>\n" );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -241,12 +249,15 @@ print( "\n<br>n" );
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzerror</function> Example</title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$error = bzerror($bz);
|
||||
|
||||
echo $error["errno"];
|
||||
echo $error["errstr"];
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -335,15 +346,18 @@ echo $error["errstr"];
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzopen</function> Example</title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$bz = bzopen("/tmp/foo.bz2", "r");
|
||||
$decompressed_file = bzread($bz, filesize("/tmp/foo.bz2"));
|
||||
bzclose($bz);
|
||||
|
||||
print( "The contents of /tmp/foo.bz2 are: " );
|
||||
print( "\n<br>n" );
|
||||
print( "\n<br>\n" );
|
||||
print( $decompressed_file );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -383,11 +397,14 @@ print( $decompressed_file );
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzread</function> Example</title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$bz = bzopen("/tmp/foo.bz2", "r");
|
||||
$str = bzread($bz, 2048);
|
||||
print( $str );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -426,12 +443,15 @@ print( $str );
|
|||
<para>
|
||||
<example>
|
||||
<title><function>bzwrite</function> Example</title>
|
||||
<programlisting role="php"><?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$str = "uncompressed data";
|
||||
$bz = bzopen("/tmp/foo.bz2", "w");
|
||||
bzwrite($bz, $str, strlen($str));
|
||||
bzclose($bz);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<reference id="ref.calendar">
|
||||
<title>Calendar functions</title>
|
||||
<titleabbrev>Calendar</titleabbrev>
|
||||
|
@ -76,12 +76,14 @@
|
|||
<example>
|
||||
<title>Calendar functions</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$jd = GregorianToJD (10,11,1970);
|
||||
echo "$jd\n";
|
||||
$gregorian = JDToGregorian ($jd);
|
||||
echo "$gregorian\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -385,9 +387,11 @@ echo "$gregorian\n";
|
|||
<example>
|
||||
<title><function>easter_date</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo date ("M-d-Y", easter_date(1999)); /* "Apr-04-1999" */
|
||||
echo date ("M-d-Y", easter_date(2000)); /* "Apr-23-2000" */
|
||||
echo date ("M-d-Y", easter_date(2001)); /* "Apr-15-2001" */
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -446,9 +450,11 @@ echo date ("M-d-Y", easter_date(2001)); /* "Apr-15-2001" */
|
|||
<example>
|
||||
<title><function>easter_days</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo easter_days (1999); /* 14, i.e. April 4 */
|
||||
echo easter_days (1492); /* 32, i.e. April 22 */
|
||||
echo easter_days (1913); /* 2, i.e. March 23 */
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.26 $ -->
|
||||
<!-- $Revision: 1.27 $ -->
|
||||
<reference id="ref.classobj">
|
||||
<title>Class/Object Functions</title>
|
||||
<titleabbrev>Classes/Objects</titleabbrev>
|
||||
|
@ -31,7 +31,8 @@
|
|||
<example>
|
||||
<title>classes.inc</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// base class with member properties and methods
|
||||
class Vegetable {
|
||||
|
@ -39,17 +40,17 @@ class Vegetable {
|
|||
var $edible;
|
||||
var $color;
|
||||
|
||||
function Vegetable( $edible, $color="green" ) {
|
||||
$this->edible = $edible;
|
||||
$this->color = $color;
|
||||
function Vegetable( $edible, $color="green" ) {
|
||||
$this->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
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -88,58 +90,60 @@ class Spinach extends Vegetable {
|
|||
<example>
|
||||
<title>test_script.php</title>
|
||||
<programlisting role="php">
|
||||
<pre>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
include "classes.inc";
|
||||
include "classes.inc";
|
||||
|
||||
// utility functions
|
||||
|
||||
function print_vars($obj) {
|
||||
$arr = get_object_vars($obj);
|
||||
while (list($prop, $val) = each($arr))
|
||||
echo "\t$prop = $val\n";
|
||||
echo "\t$prop = $val\n";
|
||||
}
|
||||
|
||||
function print_methods($obj) {
|
||||
$arr = get_class_methods(get_class($obj));
|
||||
foreach ($arr as $method)
|
||||
echo "\tfunction $method()\n";
|
||||
echo "\tfunction $method()\n";
|
||||
}
|
||||
|
||||
function class_parentage($obj, $class) {
|
||||
global $$obj;
|
||||
if (is_subclass_of($$obj, $class)) {
|
||||
echo "Object $obj belongs to class ".get_class($$obj);
|
||||
echo " a subclass of $class\n";
|
||||
echo "Object $obj belongs to class ".get_class($$obj);
|
||||
echo " a subclass of $class\n";
|
||||
} else {
|
||||
echo "Object $obj does not belong to a subclass of $class\n";
|
||||
echo "Object $obj does not belong to a subclass of $class\n";
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate 2 objects
|
||||
|
||||
$veggie = new Vegetable(true,"blue");
|
||||
$veggie = new Vegetable(true,"blue");
|
||||
$leafy = new Spinach();
|
||||
|
||||
// print out information about objects
|
||||
echo "veggie: CLASS ".get_class($veggie)."\n";
|
||||
echo "leafy: CLASS ".get_class($leafy);
|
||||
echo ", PARENT ".get_parent_class($leafy)."\n";
|
||||
echo "veggie: CLASS ".get_class($veggie)."\n";
|
||||
echo "leafy: CLASS ".get_class($leafy);
|
||||
echo ", PARENT ".get_parent_class($leafy)."\n";
|
||||
|
||||
// show veggie properties
|
||||
echo "\nveggie: Properties\n";
|
||||
echo "\nveggie: Properties\n";
|
||||
print_vars($veggie);
|
||||
|
||||
// and leafy methods
|
||||
echo "\nleafy: Methods\n";
|
||||
echo "\nleafy: Methods\n";
|
||||
print_methods($leafy);
|
||||
|
||||
echo "\nParentage:\n";
|
||||
class_parentage("leafy", "Spinach");
|
||||
class_parentage("leafy", "Vegetable");
|
||||
?>
|
||||
</pre>
|
||||
echo "\nParentage:\n";
|
||||
class_parentage("leafy", "Spinach");
|
||||
class_parentage("leafy", "Vegetable");
|
||||
?>
|
||||
</pre>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -153,10 +157,12 @@ class_parentage("leafy", "Vegetable");
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
[...]
|
||||
Parentage:
|
||||
Object leafy does not belong to a subclass of Spinach
|
||||
Object leafy belongs to class spinach a subclass of Vegetable
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -244,30 +250,32 @@ Object leafy belongs to class spinach a subclass of Vegetable
|
|||
<varname>print_info</varname> method.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Country {
|
||||
var $NAME;
|
||||
var $TLD;
|
||||
|
||||
function Country($name, $tld) {
|
||||
$this->NAME = $name;
|
||||
$this->TLD = $tld;
|
||||
$this->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");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -353,7 +361,9 @@ call_user_method ("print_info", $cntry, "\t");
|
|||
<parameter>class_name</parameter>. For example:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$class_methods = get_class_methods($my_class);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -362,7 +372,8 @@ $class_methods = get_class_methods($my_class);
|
|||
<example>
|
||||
<title><function>get_class_methods</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
class myclass {
|
||||
// constructor
|
||||
|
@ -389,7 +400,8 @@ foreach ($class_methods as $method_name) {
|
|||
echo "$method_name\n";
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -397,9 +409,11 @@ foreach ($class_methods as $method_name) {
|
|||
Will produce:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
myclass
|
||||
myfunc1
|
||||
myfunc2
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -440,7 +454,8 @@ myfunc2
|
|||
<example>
|
||||
<title><function>get_class_vars</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
class myclass {
|
||||
|
||||
|
@ -463,7 +478,8 @@ foreach ($class_vars as $name => $value) {
|
|||
echo "$name : $value\n";
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -471,8 +487,10 @@ foreach ($class_vars as $name => $value) {
|
|||
Will produce:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
var2 : xyz
|
||||
var3 : 100
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -540,24 +558,25 @@ var3 : 100
|
|||
<example>
|
||||
<title>Use of <function>get_object_vars</function></title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Point2D {
|
||||
var $x, $y;
|
||||
var $label;
|
||||
|
||||
function Point2D($x, $y) {
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->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
|
||||
// )
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.24 $ -->
|
||||
<!-- $Revision: 1.25 $ -->
|
||||
<reference id="ref.com">
|
||||
<title>COM support functions for Windows</title>
|
||||
<titleabbrev>COM</titleabbrev>
|
||||
|
@ -85,6 +85,7 @@
|
|||
<example id="example.com1">
|
||||
<title>COM example (1)</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// starting word
|
||||
$word = new COM("word.application") or die("Unable to instanciate Word");
|
||||
print "Loaded Word, version {$word->Version}\n";
|
||||
|
@ -105,6 +106,7 @@ $word->Quit();
|
|||
//free the object
|
||||
$word->Release();
|
||||
$word = null;
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -112,6 +114,7 @@ $word = null;
|
|||
<example id="example.com2">
|
||||
<title>COM example (2)</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
|
||||
$conn->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;
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.32 $ -->
|
||||
<!-- $Revision: 1.33 $ -->
|
||||
<reference id="ref.cpdf">
|
||||
<title>ClibPDF functions</title>
|
||||
<titleabbrev>ClibPDF</titleabbrev>
|
||||
|
@ -63,7 +63,8 @@
|
|||
<example>
|
||||
<title>Simple ClibPDF Example</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$cpdf = cpdf_open(0);
|
||||
cpdf_page_init($cpdf, 1, 0, 595, 842);
|
||||
cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
|
||||
|
@ -79,7 +80,8 @@ cpdf_finalize($cpdf);
|
|||
Header("Content-type: application/pdf");
|
||||
cpdf_output_buffer($cpdf);
|
||||
cpdf_close($cpdf);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<simpara>
|
||||
|
@ -90,7 +92,8 @@ cpdf_close($cpdf);
|
|||
<example>
|
||||
<title>pdfclock example from pdflib 2.0 distribution</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$radius = 200;
|
||||
$margin = 20;
|
||||
$pagecount = 40;
|
||||
|
@ -176,7 +179,8 @@ cpdf_finalize($pdf);
|
|||
Header("Content-type: application/pdf");
|
||||
cpdf_output_buffer($pdf);
|
||||
cpdf_close($pdf);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</partintro>
|
||||
|
@ -238,7 +242,8 @@ cpdf_close($pdf);
|
|||
<example>
|
||||
<title>Adding a page outline</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$cpdf = cpdf_open(0);
|
||||
cpdf_page_init($cpdf, 1, 0, 595, 842);
|
||||
cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
|
||||
|
@ -249,7 +254,8 @@ cpdf_finalize($cpdf);
|
|||
Header("Content-type: application/pdf");
|
||||
cpdf_output_buffer($cpdf);
|
||||
cpdf_close($cpdf);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -314,12 +320,14 @@ cpdf_close($cpdf);
|
|||
<example>
|
||||
<title>Text output</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
cpdf_begin_text($pdf);
|
||||
cpdf_set_font($pdf, 16, "Helvetica", "WinAnsiEncoding");
|
||||
cpdf_text($pdf, 100, 100, "Some text");
|
||||
cpdf_end_text($pdf)
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -573,12 +581,14 @@ cpdf_end_text($pdf)
|
|||
<example>
|
||||
<title>Text output</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
cpdf_begin_text($pdf);
|
||||
cpdf_set_font($pdf, 16, "Helvetica", "WinAnsiEncoding");
|
||||
cpdf_text($pdf, 100, 100, "Some text");
|
||||
cpdf_end_text($pdf)
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1069,11 +1079,13 @@ cpdf_end_text($pdf)
|
|||
<example>
|
||||
<title>Save/Restore</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
cpdf_save($pdf);
|
||||
// do all kinds of rotations, transformations, ...
|
||||
cpdf_restore($pdf)
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<!-- $Revision: 1.18 $ -->
|
||||
<reference id="ref.curl">
|
||||
<title>CURL, Client URL Library Functions</title>
|
||||
<titleabbrev>CURL</titleabbrev>
|
||||
|
@ -45,7 +45,8 @@
|
|||
<example>
|
||||
<title>Using PHP's CURL module to fetch the PHP homepage</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$ch = curl_init ("http://www.php.net/");
|
||||
$fp = fopen ("php_homepage.txt", "w");
|
||||
|
@ -57,6 +58,7 @@ curl_exec ($ch);
|
|||
curl_close ($ch);
|
||||
fclose ($fp);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -95,7 +97,8 @@ fclose ($fp);
|
|||
Initializing a new CURL session and fetching a webpage
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt ($ch, CURLOPT_URL, "http://www.zend.com/");
|
||||
|
@ -105,6 +108,7 @@ curl_exec ($ch);
|
|||
|
||||
curl_close ($ch);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<reference id="ref.cybermut">
|
||||
<title>Crédit Mutuel CyberMUT functions</title>
|
||||
<titleabbrev>CyberMUT</titleabbrev>
|
||||
|
@ -73,7 +73,8 @@
|
|||
<example>
|
||||
<title>First step of payment (equiv cgi1.c)</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Directory where are located the keys
|
||||
putenv("CMKEYDIR=/var/creditmut/cles");
|
||||
|
||||
|
@ -95,7 +96,8 @@ $VERSION="1.2";
|
|||
"Paiement par carte bancaire");
|
||||
|
||||
echo $retour;
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -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:
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$code_retour=$HTTP_GET_VARS["code-retour"];
|
||||
$texte_libre=$HTTP_GET_VARS["texte-libre"];
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</para>
|
||||
<example>
|
||||
<title>Last step of payment (equiv cgi2.c)</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Make sure that Enable Track Vars is ON.
|
||||
// Directory where are located the keys
|
||||
putenv("CMKEYDIR=/var/creditmut/cles");
|
||||
|
@ -165,10 +170,12 @@ if ($mac_ok) {
|
|||
//
|
||||
|
||||
$result=creditmut_creerreponsecm("OK");
|
||||
} else {
|
||||
$result=creditmut_creerreponsecm("Document Falsifie");}
|
||||
} else {
|
||||
$result=creditmut_creerreponsecm("Document Falsifie");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.51 $ -->
|
||||
<!-- $Revision: 1.52 $ -->
|
||||
<reference id="ref.datetime">
|
||||
<title>Date and Time functions</title>
|
||||
<titleabbrev>Date/time</titleabbrev>
|
||||
|
@ -254,8 +254,10 @@
|
|||
<example>
|
||||
<title><function>date</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo date ("l dS of F Y h:i:s A");
|
||||
echo "July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000));
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -267,7 +269,9 @@ echo "July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000));
|
|||
<example>
|
||||
<title>Escaping characters in <function>date</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo date("l \\t\h\e jS"); // prints something like 'Saturday the 8th'
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -280,10 +284,12 @@ echo date("l \\t\h\e jS"); // prints something like 'Saturday the 8th'
|
|||
<function>date</function> and <function>mktime</function>
|
||||
example
|
||||
</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$tomorrow = mktime (0,0,0,date("m") ,date("d")+1,date("Y"));
|
||||
$lastmonth = mktime (0,0,0,date("m")-1,date("d"), date("Y"));
|
||||
$nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -305,7 +311,8 @@ $nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
|
|||
<title>
|
||||
<function>date</function> Formatting
|
||||
</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Today is March 10th, 2001, 5:16:18 pm */
|
||||
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
|
||||
$today = date("m.d.y"); // 03.10.01
|
||||
|
@ -316,6 +323,7 @@ $today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day.
|
|||
$today = date("D M j G:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001
|
||||
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month
|
||||
$today = date("H:i:s"); // 17:16:17
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -408,12 +416,14 @@ $today = date("H:i:s"); // 17:16:17
|
|||
<title>
|
||||
<function>getdate</function> example
|
||||
</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$today = getdate();
|
||||
$month = $today['month'];
|
||||
$mday = $today['mday'];
|
||||
$year = $today['year'];
|
||||
echo "$month $mday, $year";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -487,8 +497,10 @@ echo "$month $mday, $year";
|
|||
<example>
|
||||
<title><function>gmdate</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo date ("M d Y H:i:s", mktime (0,0,0,1,1,1998));
|
||||
echo gmdate ("M d Y H:i:s", mktime (0,0,0,1,1,1998));
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -554,9 +566,11 @@ echo gmdate ("M d Y H:i:s", mktime (0,0,0,1,1,1998));
|
|||
<example>
|
||||
<title><function>gmstrftime</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
setlocale ('LC_TIME', 'en_US');
|
||||
echo strftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
|
||||
echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -678,6 +692,7 @@ echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
|
|||
<example>
|
||||
<title><function>microtime</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
|
@ -685,7 +700,7 @@ function getmicrotime(){
|
|||
|
||||
$time_start = getmicrotime();
|
||||
|
||||
for ($i=0; $i < 1000; $i++){
|
||||
for ($i=0; $i < 1000; $i++){
|
||||
//do nothing, 1000 times
|
||||
}
|
||||
|
||||
|
@ -693,6 +708,7 @@ $time_end = getmicrotime();
|
|||
$time = $time_end - $time_start;
|
||||
|
||||
echo "Did nothing in $time seconds";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -759,11 +775,13 @@ echo "Did nothing in $time seconds";
|
|||
lines produces the string "Jan-01-1998".
|
||||
<example>
|
||||
<title><function>mktime</function> example</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo date ("M-d-Y", mktime (0,0,0,12,32,1997));
|
||||
echo date ("M-d-Y", mktime (0,0,0,13,1,1997));
|
||||
echo date ("M-d-Y", mktime (0,0,0,1,1,1998));
|
||||
echo date ("M-d-Y", mktime (0,0,0,1,1,98));
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<parameter>Year</parameter> may be a two or four digit value,
|
||||
|
@ -779,11 +797,13 @@ echo date ("M-d-Y", mktime (0,0,0,1,1,98));
|
|||
<example>
|
||||
<title>Last day of next month</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$lastday = mktime (0,0,0,3,0,2000);
|
||||
echo strftime ("Last day in Feb 2000 is: %d", $lastday);
|
||||
|
||||
$lastday = mktime (0,0,0,4,-31,2000);
|
||||
echo strftime ("Last day in Feb 2000 is: %d", $lastday);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1022,6 +1042,7 @@ echo strftime ("Last day in Feb 2000 is: %d", $lastday);
|
|||
<example>
|
||||
<title><function>strftime</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
setlocale ("LC_TIME", "C");
|
||||
print (strftime ("%A in Finnish is "));
|
||||
setlocale ("LC_TIME", "fi_FI");
|
||||
|
@ -1030,6 +1051,7 @@ setlocale ("LC_TIME", "fr_CA");
|
|||
print (strftime ("%A and in German "));
|
||||
setlocale ("LC_TIME", "de_DE");
|
||||
print (strftime ("%A.\n"));
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
This example works if you have the respective locales installed
|
||||
|
@ -1093,11 +1115,13 @@ print (strftime ("%A.\n"));
|
|||
<example>
|
||||
<title><function>strtotime</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo strtotime ("now") . "\n";
|
||||
echo strtotime ("10 September 2000") . "\n";
|
||||
echo strtotime ("+1 day") . "\n";
|
||||
echo strtotime ("+1 week") . "\n";
|
||||
echo strtotime ("+1 week 2 days 4 hours 2 seconds") . "\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<reference id="ref.dba">
|
||||
<title>Database (dbm-style) abstraction layer functions</title>
|
||||
<titleabbrev>dba</titleabbrev>
|
||||
|
@ -106,7 +106,8 @@
|
|||
<example>
|
||||
<title>DBA example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$id = dba_open ("/tmp/test.db", "n", "db2");
|
||||
|
||||
|
@ -123,7 +124,8 @@ if (dba_exists ("key", $id)) {
|
|||
}
|
||||
|
||||
dba_close ($id);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -147,7 +149,8 @@ dba_close ($id);
|
|||
<example>
|
||||
<title>Traversing a database</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
# ...open database...
|
||||
|
||||
|
@ -160,10 +163,11 @@ while ($key != false) {
|
|||
$key = dba_nextkey ($id);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($handle_later); $i++)
|
||||
for ($i = 0; $i < count($handle_later); $i++)
|
||||
dba_delete ($handle_later[$i], $id);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<reference id="ref.dbase">
|
||||
<title>dBase functions</title>
|
||||
<titleabbrev>dBase</titleabbrev>
|
||||
|
@ -104,6 +104,7 @@
|
|||
<example>
|
||||
<title>Creating a dBase database file</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// "database" name
|
||||
$dbname = "/tmp/test.dbf";
|
||||
|
||||
|
@ -119,7 +120,8 @@ $def =
|
|||
|
||||
// creation
|
||||
if (!dbase_create($dbname, $def))
|
||||
print "<strong>Error!</strong>";
|
||||
print "<strong>Error!</strong>";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -351,11 +353,13 @@ if (!dbase_create($dbname, $def))
|
|||
<example>
|
||||
<title>Using <function>dbase_numfields</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$rec = dbase_get_record($db, $recno);
|
||||
$nf = dbase_numfields($db);
|
||||
for ($i=0; $i < $nf; $i++) {
|
||||
print $rec[$i]."<br>\n";
|
||||
for ($i=0; $i < $nf; $i++) {
|
||||
print $rec[$i]."<br>\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<reference id="ref.dbm">
|
||||
<title>DBM Functions</title>
|
||||
<titleabbrev>DBM</titleabbrev>
|
||||
|
@ -16,6 +16,7 @@
|
|||
<example>
|
||||
<title>DBM example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$dbm = dbmopen ("lastseen", "w");
|
||||
if (dbmexists ($dbm, $userid)) {
|
||||
$last_seen = dbmfetch ($dbm, $userid);
|
||||
|
@ -25,6 +26,7 @@ if (dbmexists ($dbm, $userid)) {
|
|||
do_stuff();
|
||||
dbmreplace ($dbm, $userid, time());
|
||||
dbmclose ($dbm);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -263,11 +265,13 @@ dbmclose ($dbm);
|
|||
<example>
|
||||
<title>Visiting every key/value pair in a DBM database</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$key = dbmfirstkey ($dbm_id);
|
||||
while ($key) {
|
||||
echo "$key = " . dbmfetch ($dbm_id, $key) . "\n";
|
||||
$key = dbmnextkey ($dbm_id, $key);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.20 $ -->
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<reference id="ref.dbx">
|
||||
<title>dbx functions</title>
|
||||
<titleabbrev>dbx</titleabbrev>
|
||||
|
@ -53,12 +53,14 @@
|
|||
<example>
|
||||
<title><function>dbx_close</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = dbx_connect ("mysql", "localhost", "db", "username", "password")
|
||||
or die ("Could not connect");
|
||||
print("Connected successfully");
|
||||
dbx_close($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -146,10 +148,12 @@ dbx_close($link);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = dbx_connect ("mysql", "localhost", "db", "username", "password");
|
||||
mysql_close ($link->handle); // dbx_close($link) would be better here
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -162,12 +166,14 @@ mysql_close ($link->handle); // dbx_close($link) would be better here
|
|||
<example>
|
||||
<title><function>dbx_connect</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = dbx_connect ("odbc", "", "db", "username", "password", DBX_PERSISTENT)
|
||||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
dbx_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -212,7 +218,8 @@ dbx_close ($link);
|
|||
<example>
|
||||
<title><function>dbx_error</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = dbx_connect ("mysql", "localhost", "db", "username", "password")
|
||||
or die ("Could not connect");
|
||||
$result = dbx_query ($link, "select id from nonexistingtbl");
|
||||
|
@ -220,7 +227,8 @@ if ($result==0) {
|
|||
echo dbx_error ($link);
|
||||
}
|
||||
dbx_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -292,8 +300,10 @@ dbx_close ($link);
|
|||
<para>
|
||||
<informalexample role="php">
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$result = dbx_query ($link, "SELECT id FROM tbl");
|
||||
mysql_field_len ($result->handle, 0);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -304,8 +314,10 @@ mysql_field_len ($result->handle, 0);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$result = dbx_query ($link, "SELECT id FROM tbl");
|
||||
echo "result size: " . $result->rows . " x " . $result->cols . "<br>\n";
|
||||
echo "result size: " . $result->rows . " x " . $result->cols . "<br>\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -318,9 +330,11 @@ echo "result size: " . $result->rows . " x " . $result->cols . "<br>\n";
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$result = dbx_query ($link, "SELECT id FROM tbl");
|
||||
echo "column name: " . $result->info["name"][0] . "<br>\n";
|
||||
echo "column type: " . $result->info["type"][0] . "<br>\n";
|
||||
echo "column name: " . $result->info["name"][0] . "<br>\n";
|
||||
echo "column type: " . $result->info["type"][0] . "<br>\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -333,42 +347,44 @@ echo "column type: " . $result->info["type"][0] . "<br>\n";
|
|||
<example>
|
||||
<title><function>dbx_query</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = dbx_connect ("odbc", "", "db", "username", "password")
|
||||
or die ("Could not connect");
|
||||
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl");
|
||||
if ($result==0) echo "Query failed\n<br>";
|
||||
if ($result==0) echo "Query failed\n<br>";
|
||||
elseif ($result==1) {
|
||||
echo "Query executed successfully\n<br>";
|
||||
echo "Query executed successfully\n<br>";
|
||||
} 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 "<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 "</tr>\n";
|
||||
for ($row=0; $row<$rows; ++$row){
|
||||
echo "<tr>";
|
||||
for ($col=0; $col<$cols; ++$col) {
|
||||
echo "<td>-{$result->data[$row][$col]}-</td>";
|
||||
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 "</tr>\n";
|
||||
echo "</tr>\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 "</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 "</table><p>\n";
|
||||
echo "</table><p>\n";
|
||||
}
|
||||
dbx_close($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -408,7 +424,8 @@ dbx_close($link);
|
|||
<example>
|
||||
<title><function>dbx_sort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function user_re_order ($a, $b) {
|
||||
$rv = dbx_compare ($a, $b, "parentid", DBX_CMP_DESC);
|
||||
if (!$rv) $rv = dbx_compare ($a, $b, "id");
|
||||
|
@ -418,11 +435,12 @@ function user_re_order ($a, $b) {
|
|||
$link = dbx_connect ("odbc", "", "db", "username", "password")
|
||||
or die ("Could not connect");
|
||||
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
|
||||
echo "resulting data is now ordered by id<br>";
|
||||
echo "resulting data is now ordered by id<br>";
|
||||
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<br>";
|
||||
dbx_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -469,7 +487,8 @@ dbx_close ($link);
|
|||
<example>
|
||||
<title><function>dbx_compare</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function user_re_order ($a, $b) {
|
||||
$rv = dbx_compare ($a, $b, "parentid", DBX_CMP_DESC);
|
||||
if (!$rv) {
|
||||
|
@ -481,11 +500,12 @@ function user_re_order ($a, $b) {
|
|||
$link = dbx_connect ("odbc", "", "db", "username", "password")
|
||||
or die ("Could not connect");
|
||||
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
|
||||
echo "resulting data is now ordered by id<br>";
|
||||
echo "resulting data is now ordered by id<br>";
|
||||
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<br>";
|
||||
dbx_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.24 $ -->
|
||||
<!-- $Revision: 1.25 $ -->
|
||||
<reference id="ref.dir">
|
||||
<title>Directory functions</title>
|
||||
<titleabbrev>Directories</titleabbrev>
|
||||
|
@ -90,13 +90,15 @@
|
|||
<example>
|
||||
<title><function>dir</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$d = dir("/etc");
|
||||
echo "Handle: ".$d->handle."<br>\n";
|
||||
echo "Path: ".$d->path."<br>\n";
|
||||
echo "Handle: ".$d->handle."<br>\n";
|
||||
echo "Path: ".$d->path."<br>\n";
|
||||
while ($entry = $d->read()) {
|
||||
echo $entry."<br>\n";
|
||||
echo $entry."<br>\n";
|
||||
}
|
||||
$d->close();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -173,7 +175,8 @@ $d->close();
|
|||
<example>
|
||||
<title><function>opendir</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
if ($dir = @opendir("/tmp")) {
|
||||
while (($file = readdir($dir)) !== false) {
|
||||
|
@ -182,7 +185,8 @@ if ($dir = @opendir("/tmp")) {
|
|||
closedir($dir);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -208,8 +212,9 @@ if ($dir = @opendir("/tmp")) {
|
|||
<example>
|
||||
<title>List all files in the current directory</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// Note that !== did not exist until 4.0.0-RC2
|
||||
<?php
|
||||
<?php
|
||||
$handle=opendir('.');
|
||||
echo "Directory handle: $handle\n";
|
||||
echo "Files:\n";
|
||||
|
@ -217,7 +222,8 @@ while (false !== ($file = readdir($handle))) {
|
|||
echo "$file\n";
|
||||
}
|
||||
closedir($handle);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -232,7 +238,8 @@ closedir($handle);
|
|||
and <literal>..</literal>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$handle = opendir('.');
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
|
@ -240,7 +247,8 @@ while (false !== ($file = readdir($handle))) {
|
|||
}
|
||||
}
|
||||
closedir($handle);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.24 $ -->
|
||||
<!-- $Revision: 1.25 $ -->
|
||||
<reference id="ref.domxml">
|
||||
<title>DOM XML functions</title>
|
||||
<titleabbrev>DOM XML</titleabbrev>
|
||||
|
@ -523,38 +523,40 @@
|
|||
<example>
|
||||
<title>Retrieving root element</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$xmlstr = "<?xml version='1.0' standalone='yes'?>
|
||||
<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
|
||||
[ <!ENTITY sp \"spanish\">
|
||||
<![CDATA[
|
||||
<?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'>
|
||||
<!-- lsfj -->
|
||||
<chapter language='en'><title language='en'>Title</title>
|
||||
<para language='ge'>
|
||||
&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>";
|
||||
<!-- 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>";
|
||||
|
||||
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);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -586,13 +588,15 @@ print_r($root);
|
|||
<example>
|
||||
<title>Creating a simple HTML document header</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new_xmldoc("1.0");
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
echo $doc->dumpmem();
|
||||
?>
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
echo $doc->dumpmem();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -704,14 +708,16 @@ echo $doc->dumpmem();
|
|||
<example>
|
||||
<title>Adding an attribute to an element</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new_xmldoc("1.0");
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
$head->set_attribute("Language", "ge");
|
||||
echo $doc->dumpmem();
|
||||
?>
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
$head->set_attribute("Language", "ge");
|
||||
echo $doc->dumpmem();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -744,14 +750,16 @@ echo $doc->dumpmem();
|
|||
<example>
|
||||
<title>Adding an attribute to an element</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new_xmldoc("1.0");
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
$head->set_attribute("Language", "ge");
|
||||
$children = $head->children();
|
||||
?>
|
||||
$root = $doc->add_root("HTML");
|
||||
$head = $root->new_child("HEAD", "");
|
||||
$head->new_child("TITLE", "Hier der Titel");
|
||||
$head->set_attribute("Language", "ge");
|
||||
$children = $head->children();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.19 $ -->
|
||||
<!-- $Revision: 1.20 $ -->
|
||||
<reference id="ref.errorfunc">
|
||||
<title>Error Handling and Logging Functions</title>
|
||||
<titleabbrev>Errors and Logging</titleabbrev>
|
||||
|
@ -109,6 +109,7 @@
|
|||
<example role="php">
|
||||
<title><function>error_log</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// Send notification through the server log if we can not
|
||||
// connect to the database.
|
||||
if (!Ora_Logon ($username, $password)) {
|
||||
|
@ -125,6 +126,7 @@ if (!($foo = allocate_new_foo()) {
|
|||
error_log ("You messed up!", 2, "127.0.0.1:7000");
|
||||
error_log ("You messed up!", 2, "loghost");
|
||||
error_log ("You messed up!", 3, "/var/tmp/my-errors.log");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -156,6 +158,7 @@ error_log ("You messed up!", 3, "/var/tmp/my-errors.log");
|
|||
<example role="php">
|
||||
<title>Error Integer changes</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
error_reporting (55); // PHP 3 equivalent to E_ALL ^ E_NOTICE
|
||||
|
||||
/* ...in PHP 4, '55' would mean (E_ERROR | E_WARNING | E_PARSE |
|
||||
|
@ -164,6 +167,7 @@ E_CORE_ERROR | E_CORE_WARNING) */
|
|||
error_reporting (2039); // PHP 4 equivalent to E_ALL ^ E_NOTICE
|
||||
|
||||
error_reporting (E_ALL ^ E_NOTICE); // The same in both PHP 3 and 4
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
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
|
|||
<example role="php">
|
||||
<title><function>error_reporting</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
error_reporting(0);
|
||||
/* Turn off all reporting */
|
||||
|
||||
|
@ -265,6 +270,7 @@ error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // New syntax for PH
|
|||
error_reporting (63); // Old syntax, PHP 2/3
|
||||
error_reporting (E_ALL); // New syntax for PHP 3/4
|
||||
/* report all PHP errors */
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -341,7 +347,8 @@ error_reporting (E_ALL); // New syntax for PHP 3/4
|
|||
<function>trigger_error</function>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// redefine the user error constants - PHP 4 only
|
||||
define (FATAL,E_USER_ERROR);
|
||||
|
@ -355,36 +362,36 @@ error_reporting (FATAL | ERROR | WARNING);
|
|||
function myErrorHandler ($errno, $errstr, $errfile, $errline) {
|
||||
switch ($errno) {
|
||||
case FATAL:
|
||||
echo "<b>FATAL</b> [$errno] $errstr<br>\n";
|
||||
echo " Fatal error in line ".$errline." of file ".$errfile;
|
||||
echo ", PHP ".PHP_VERSION." (".PHP_OS.")<br>\n";
|
||||
echo "Aborting...<br>\n";
|
||||
echo "<b>FATAL</b> [$errno] $errstr<br>\n";
|
||||
echo " Fatal error in line ".$errline." of file ".$errfile;
|
||||
echo ", PHP ".PHP_VERSION." (".PHP_OS.")<br>\n";
|
||||
echo "Aborting...<br>\n";
|
||||
exit -1;
|
||||
break;
|
||||
case ERROR:
|
||||
echo "<b>ERROR</b> [$errno] $errstr<br>\n";
|
||||
echo "<b>ERROR</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
case WARNING:
|
||||
echo "<b>WARNING</b> [$errno] $errstr<br>\n";
|
||||
echo "<b>WARNING</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
default:
|
||||
echo "Unkown error type: [$errno] $errstr<br>\n";
|
||||
echo "Unkown error type: [$errno] $errstr<br>\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<count($vect); $i++) {
|
||||
if (!is_numeric($vect[$i]))
|
||||
trigger_error("Value at position $i is not a number, using 0 (zero)",
|
||||
trigger_error("Value at position $i is not a number, using 0 (zero)",
|
||||
WARNING);
|
||||
$temp[$i] = log($scale) * $vect[$i];
|
||||
}
|
||||
|
@ -392,64 +399,67 @@ function scale_by_log ($vect, $scale) {
|
|||
}
|
||||
|
||||
// set to the user defined error handler
|
||||
$old_error_handler = set_error_handler("myErrorHandler");
|
||||
$old_error_handler = set_error_handler("myErrorHandler");
|
||||
|
||||
// trigger some errors, first define a mixed array with a non-numeric item
|
||||
echo "vector a\n";
|
||||
$a = array(2,3,"foo",5.5,43.3,21.11);
|
||||
echo "vector a\n";
|
||||
$a = array(2,3,"foo",5.5,43.3,21.11);
|
||||
print_r($a);
|
||||
|
||||
// now generate second array, generating a warning
|
||||
echo "----\nvector b - a warning (b = log(PI) * a)\n";
|
||||
echo "----\nvector b - a warning (b = log(PI) * a)\n";
|
||||
$b = scale_by_log($a, M_PI);
|
||||
print_r($b);
|
||||
|
||||
// this is trouble, we pass a string instead of an array
|
||||
echo "----\nvector c - an error\n";
|
||||
$c = scale_by_log("not array",2.3);
|
||||
echo "----\nvector c - an error\n";
|
||||
$c = scale_by_log("not array",2.3);
|
||||
var_dump($c);
|
||||
|
||||
// this is a critical error, log of zero or negative number is undefined
|
||||
echo "----\nvector d - fatal error\n";
|
||||
echo "----\nvector d - fatal error\n";
|
||||
$d = scale_by_log($a, -2.5);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
And when you run this sample script, the output will be
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
vector a
|
||||
Array
|
||||
(
|
||||
[0] => 2
|
||||
[1] => 3
|
||||
[2] => foo
|
||||
[3] => 5.5
|
||||
[4] => 43.3
|
||||
[5] => 21.11
|
||||
[0] => 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>
|
||||
<b>WARNING</b> [1024] Value at position 2 is not a number, using 0 (zero)<br>
|
||||
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>
|
||||
<b>ERROR</b> [512] Incorrect input vector, array of values expected<br>
|
||||
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>
|
||||
<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>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -507,8 +517,10 @@ Aborting...<br>
|
|||
For example:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
if (assert ($divisor == 0))
|
||||
trigger_error ("Cannot divide by zero", E_USER_ERROR);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<note>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
<reference id="ref.exec">
|
||||
<title>Program Execution functions</title>
|
||||
<titleabbrev>Program Execution</titleabbrev>
|
||||
|
@ -38,7 +38,9 @@
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
system("ls ".escapeshellarg($dir));
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -76,10 +78,12 @@ system("ls ".escapeshellarg($dir));
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$e = escapeshellcmd($userinput);
|
||||
system("echo $e"); // here we don't care if $e has spaces
|
||||
$f = escapeshellcmd($filename);
|
||||
system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\""); // and here we do, so we use quotes
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.31 $ -->
|
||||
<!-- $Revision: 1.32 $ -->
|
||||
<reference id="ref.fbsql">
|
||||
<title>FrontBase Functions</title>
|
||||
<titleabbrev>FrontBase</titleabbrev>
|
||||
|
@ -194,12 +194,14 @@
|
|||
<example>
|
||||
<title><function>fbsql_close</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_connect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
fbsql_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -295,14 +297,16 @@
|
|||
<example>
|
||||
<title><function>fbsql_connect</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$link = fbsql_connect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
fbsql_close ($link);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -339,7 +343,8 @@
|
|||
<example>
|
||||
<title><function>fbsql_create_db</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
if (fbsql_create_db ("my_db")) {
|
||||
|
@ -347,7 +352,8 @@
|
|||
} else {
|
||||
printf("Error creating database: %s\n", fbsql_error ());
|
||||
}
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -385,7 +391,8 @@
|
|||
<example>
|
||||
<title><function>fbsql_create_blob</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
$filename = "blobfile.bin";
|
||||
|
@ -397,7 +404,8 @@
|
|||
|
||||
$sql = "INSERT INTO BLOB_TABLE (BLOB_COLUMN) VALUES ($blobHandle);";
|
||||
$rs = fbsql_query($sql, $link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -438,7 +446,8 @@
|
|||
<example>
|
||||
<title><function>fbsql_create_clob</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
$filename = "clob_file.txt";
|
||||
|
@ -450,7 +459,8 @@
|
|||
|
||||
$sql = "INSERT INTO CLOB_TABLE (CLOB_COLUMN) VALUES ($clobHandle);";
|
||||
$rs = fbsql_query($sql, $link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -538,7 +548,8 @@
|
|||
<example>
|
||||
<title><function>fbsql_data_seek</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
|
||||
|
@ -560,11 +571,12 @@
|
|||
if(!($row = fbsql_fetch_object ($result)))
|
||||
continue;
|
||||
|
||||
printf("%s %s<BR>\n", $row->last_name, $row->first_name);
|
||||
printf("%s %s<BR>\n", $row->last_name, $row->first_name);
|
||||
}
|
||||
|
||||
fbsql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -751,14 +763,16 @@
|
|||
sure you check the value before calling another fbsql function.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect("marliesle");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
fbsql_select_db("nonexistentdb");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
$conn = fbsql_query("SELECT * FROM nonexistenttable;");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
?>
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -803,14 +817,16 @@ echo fbsql_errno().": ".fbsql_error()."<BR>";
|
|||
sure you check the value before calling another fbsql function.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect("marliesle");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
fbsql_select_db("nonexistentdb");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
$conn = fbsql_query("SELECT * FROM nonexistenttable;");
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
?>
|
||||
echo fbsql_errno().": ".fbsql_error()."<BR>";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -859,7 +875,9 @@ echo fbsql_errno().": ".fbsql_error()."<BR>";
|
|||
make an alias for the column.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
select t1.f1 as foo t2.f1 as bar from t1, t2
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -883,17 +901,19 @@ select t1.f1 as foo t2.f1 as bar from t1, t2
|
|||
<example>
|
||||
<title><function>fbsql_fetch_array</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect ($host, $user, $password);
|
||||
$result = fbsql_db_query ("database","select user_id, fullname from table");
|
||||
while ($row = fbsql_fetch_array ($result)) {
|
||||
echo "user_id: ".$row["user_id"]."<br>\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"]."<br>\n";
|
||||
echo "user_id: ".$row[0]."<br>\n";
|
||||
echo "fullname: ".$row["fullname"]."<br>\n";
|
||||
echo "fullname: ".$row[1]."<br>\n";
|
||||
}
|
||||
fbsql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -945,7 +965,8 @@ fbsql_free_result ($result);
|
|||
<example>
|
||||
<title><function>fbsql_fetch_assoc</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect ($host, $user, $password);
|
||||
$result = fbsql_db_query ("database","select * from table");
|
||||
while ($row = fbsql_fetch_assoc ($result)) {
|
||||
|
@ -953,7 +974,8 @@ while ($row = fbsql_fetch_assoc ($result)) {
|
|||
echo $row["fullname"];
|
||||
}
|
||||
fbsql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -1021,30 +1043,32 @@ fbsql_free_result ($result);
|
|||
<example>
|
||||
<title><function>fbsql_fetch_field</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect ($host, $user, $password)
|
||||
or die ("Could not connect");
|
||||
$result = fbsql_db_query ("database", "select * from table")
|
||||
or die ("Query failed");
|
||||
# get column metadata
|
||||
$i = 0;
|
||||
while ($i < fbsql_num_fields ($result)) {
|
||||
echo "Information for column $i:<BR>\n";
|
||||
while ($i < fbsql_num_fields ($result)) {
|
||||
echo "Information for column $i:<BR>\n";
|
||||
$meta = fbsql_fetch_field ($result);
|
||||
if (!$meta) {
|
||||
echo "No information available<BR>\n";
|
||||
echo "No information available<BR>\n";
|
||||
}
|
||||
echo "<PRE>
|
||||
echo "<PRE>
|
||||
max_length: $meta->max_length
|
||||
name: $meta->name
|
||||
not_null: $meta->not_null
|
||||
table: $meta->table
|
||||
type: $meta->type
|
||||
</PRE>";
|
||||
</PRE>";
|
||||
$i++;
|
||||
}
|
||||
fbsql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -1131,7 +1155,8 @@ fbsql_free_result ($result);
|
|||
<example>
|
||||
<title><function>fbsql_fetch_object</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect ($host, $user, $password);
|
||||
$result = fbsql_db_query ("database", "select * from table");
|
||||
while ($row = fbsql_fetch_object ($result)) {
|
||||
|
@ -1139,7 +1164,8 @@ while ($row = fbsql_fetch_object ($result)) {
|
|||
echo $row->fullname;
|
||||
}
|
||||
fbsql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1248,6 +1274,7 @@ fbsql_free_result ($result);
|
|||
<example>
|
||||
<title><function>fbsql_field_name</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// The users table consists of three fields:
|
||||
// user_id
|
||||
// username
|
||||
|
@ -1257,6 +1284,7 @@ $res = fbsql_db_query("users", "select * from users", $link);
|
|||
|
||||
echo fbsql_field_name($res, 0) . "\n";
|
||||
echo fbsql_field_name($res, 2);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1264,8 +1292,10 @@ echo fbsql_field_name($res, 2);
|
|||
The above example would produce the following output:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
user_id
|
||||
password
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1372,7 +1402,8 @@ password
|
|||
<example>
|
||||
<title><function>fbsql_field_type</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
fbsql_connect ("localhost", "_SYSTEM", "");
|
||||
fbsql_select_db ("wisconsin");
|
||||
|
@ -1381,19 +1412,20 @@ $fields = fbsql_num_fields ($result);
|
|||
$rows = fbsql_num_rows ($result);
|
||||
$i = 0;
|
||||
$table = fbsql_field_table ($result, $i);
|
||||
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
|
||||
echo "The table has the following fields <BR>";
|
||||
while ($i < $fields) {
|
||||
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
|
||||
echo "The table has the following fields <BR>";
|
||||
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."<BR>";
|
||||
$i++;
|
||||
}
|
||||
fbsql_close();
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1498,12 +1530,14 @@ fbsql_close();
|
|||
<example>
|
||||
<title><function>fbsql_list_dbs</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$link = fbsql_connect('localhost', 'myname', 'secret');
|
||||
$db_list = fbsql_list_dbs($link);
|
||||
|
||||
while ($row = fbsql_fetch_object($db_list)) {
|
||||
echo $row->Database . "\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1511,10 +1545,12 @@ while ($row = fbsql_fetch_object($db_list)) {
|
|||
The above example would produce the following output:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
database1
|
||||
database2
|
||||
database3
|
||||
...
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1566,14 +1602,16 @@ database3
|
|||
<example>
|
||||
<title><function>fbsql_list_fields</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$link = fbsql_connect('localhost', 'myname', 'secret');
|
||||
|
||||
$fields = fbsql_list_fields("database1", "table1", $link);
|
||||
$columns = fbsql_num_fields($fields);
|
||||
|
||||
for ($i = 0; $i < $columns; $i++) {
|
||||
for ($i = 0; $i < $columns; $i++) {
|
||||
echo fbsql_field_name($fields, $i) . "\n";;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1581,10 +1619,12 @@ for ($i = 0; $i < $columns; $i++) {
|
|||
The above example would produce the following output:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
field1
|
||||
field2
|
||||
field3
|
||||
...
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1649,7 +1689,8 @@ field3
|
|||
<example>
|
||||
<title><function>fbsql_next_result</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_connect ("localhost", "_SYSTEM", "secret");
|
||||
fbsql_select_db("MyDB", $link);
|
||||
$SQL = "Select * from table1; select * from table2;";
|
||||
|
@ -1660,7 +1701,8 @@ field3
|
|||
} while (fbsql_next_result($rs));
|
||||
fbsql_free_result($rs);
|
||||
fbsql_close ($link);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -1714,7 +1756,8 @@ field3
|
|||
<example>
|
||||
<title><function>fbsql_num_rows</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$link = fbsql_connect("localhost", "username", "password");
|
||||
fbsql_select_db("database", $link);
|
||||
|
@ -1724,7 +1767,8 @@ $num_rows = fbsql_num_rows($result);
|
|||
|
||||
echo "$num_rows Rows\n";
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1840,10 +1884,12 @@ echo "$num_rows Rows\n";
|
|||
<example>
|
||||
<title><function>fbsql_query</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$result = fbsql_query ("SELECT * WHERE 1=1")
|
||||
or die ("Invalid query");
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1855,10 +1901,12 @@ $result = fbsql_query ("SELECT * WHERE 1=1")
|
|||
<example>
|
||||
<title><function>fbsql_query</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$result = fbsql_query ("SELECT my_col FROM my_tbl")
|
||||
or die ("Invalid query");
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1929,7 +1977,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl")
|
|||
<example>
|
||||
<title><function>fbsql_read_blob</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
$sql = "SELECT BLOB_COLUMN FROM BLOB_TABLE;";
|
||||
|
@ -1945,7 +1994,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl")
|
|||
$blob_data = fbsql_read_blob($row_data[0]);
|
||||
fbsql_free_result($rs);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -1991,7 +2041,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl")
|
|||
<example>
|
||||
<title><function>fbsql_read_clob</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = fbsql_pconnect ("localhost", "_SYSTEM", "secret")
|
||||
or die ("Could not connect");
|
||||
$sql = "SELECT CLOB_COLUMN FROM CLOB_TABLE;";
|
||||
|
@ -2007,7 +2058,8 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl")
|
|||
$clob_data = fbsql_read_clob($row_data[0]);
|
||||
fbsql_free_result($rs);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -2293,16 +2345,18 @@ $result = fbsql_query ("SELECT my_col FROM my_tbl")
|
|||
<example>
|
||||
<title><function>fbsql_tablename</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
fbsql_connect ("localhost", "_SYSTEM", "");
|
||||
$result = fbsql_list_tables ("wisconsin");
|
||||
$i = 0;
|
||||
while ($i < fbsql_num_rows ($result)) {
|
||||
while ($i < fbsql_num_rows ($result)) {
|
||||
$tb_names[$i] = fbsql_tablename ($result, $i);
|
||||
echo $tb_names[$i] . "<BR>";
|
||||
echo $tb_names[$i] . "<BR>";
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
<reference id="ref.fdf">
|
||||
<title>Forms Data Format functions</title>
|
||||
<titleabbrev>FDF</titleabbrev>
|
||||
|
@ -58,7 +58,8 @@
|
|||
<example>
|
||||
<title>Evaluating a FDF document</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Save the FDF data into a temp file
|
||||
$fdffp = fopen("test.fdf", "w");
|
||||
fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA));
|
||||
|
@ -70,27 +71,28 @@ fclose($fdffp);
|
|||
// show_publisher and show_preparer.
|
||||
$fdf = fdf_open("test.fdf");
|
||||
$volume = fdf_get_value($fdf, "volume");
|
||||
echo "The volume field has the value '<B>$volume</B>'<BR>";
|
||||
echo "The volume field has the value '<B>$volume</B>'<BR>";
|
||||
|
||||
$date = fdf_get_value($fdf, "date");
|
||||
echo "The date field has the value '<B>$date</B>'<BR>";
|
||||
echo "The date field has the value '<B>$date</B>'<BR>";
|
||||
|
||||
$comment = fdf_get_value($fdf, "comment");
|
||||
echo "The comment field has the value '<B>$comment</B>'<BR>";
|
||||
echo "The comment field has the value '<B>$comment</B>'<BR>";
|
||||
|
||||
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 '<B>$publisher</B>'<BR>";
|
||||
} else
|
||||
echo "Publisher shall not be shown.<BR>";
|
||||
echo "Publisher shall not be shown.<BR>";
|
||||
|
||||
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 '<B>$preparer</B>'<BR>";
|
||||
} else
|
||||
echo "Preparer shall not be shown.<BR>";
|
||||
echo "Preparer shall not be shown.<BR>";
|
||||
fdf_close($fdf);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
|
@ -122,7 +124,8 @@ fdf_close($fdf);
|
|||
<example>
|
||||
<title>Accessing the form data</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Save the FDF data into a temp file
|
||||
$fdffp = fopen("test.fdf", "w");
|
||||
fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA));
|
||||
|
@ -132,7 +135,8 @@ fclose($fdffp);
|
|||
$fdf = fdf_open("test.fdf");
|
||||
...
|
||||
fdf_close($fdf);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
|
||||
|
@ -185,7 +189,8 @@ fdf_close($fdf);
|
|||
<example>
|
||||
<title>Populating a PDF document</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$outfdf = fdf_create();
|
||||
fdf_set_value($outfdf, "volume", $volume, 0);
|
||||
|
||||
|
@ -196,7 +201,8 @@ Header("Content-type: application/vnd.fdf");
|
|||
$fp = fopen("outtest.fdf", "r");
|
||||
fpassthru($fp);
|
||||
unlink("outtest.fdf");
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.87 $ -->
|
||||
<!-- $Revision: 1.88 $ -->
|
||||
<reference id="ref.filesystem">
|
||||
<title>Filesystem functions</title>
|
||||
<titleabbrev>Filesystem</titleabbrev>
|
||||
|
@ -36,9 +36,11 @@
|
|||
<example>
|
||||
<title><function>basename</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$path = "/home/httpd/html/index.php";
|
||||
$file = basename ($path); // $file is set to "index.php"
|
||||
$file = basename ($path,".php"); // $file is set to "index"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -115,9 +117,11 @@ $file = basename ($path,".php"); // $file is set to "index"
|
|||
you need to prefix <parameter>mode</parameter> with a zero (0):
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
chmod ("/somedir/somefile", 755); // decimal; probably incorrect
|
||||
chmod ("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect
|
||||
chmod ("/somedir/somefile", 0755); // octal; correct value of mode
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -238,9 +242,11 @@ chmod ("/somedir/somefile", 0755); // octal; correct value of mode
|
|||
<example>
|
||||
<title><function>copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (!copy($file, $file.'.bak')) {
|
||||
print ("failed to copy $file...<br>\n");
|
||||
print ("failed to copy $file...<br>\n");
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -300,8 +306,10 @@ if (!copy($file, $file.'.bak')) {
|
|||
<example>
|
||||
<title><function>dirname</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$path = "/etc/passwd";
|
||||
$file = dirname ($path); // $file is set to "/etc"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -333,8 +341,10 @@ $file = dirname ($path); // $file is set to "/etc"
|
|||
<example>
|
||||
<title><function>disk_free_space</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$df = disk_free_space("/"); // $df contains the number of bytes
|
||||
// available on "/"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -384,8 +394,10 @@ $df = disk_free_space("/"); // $df contains the number of bytes
|
|||
<example>
|
||||
<title><function>disk_total_space</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$df = disk_total_space("/"); // $df contains the total number of
|
||||
// bytes available on "/"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -554,17 +566,19 @@ $df = disk_total_space("/"); // $df contains the total number of
|
|||
contents of a CSV file
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$row = 1;
|
||||
$fp = fopen ("test.csv","r");
|
||||
while ($data = fgetcsv ($fp, 1000, ",")) {
|
||||
$num = count ($data);
|
||||
print "<p> $num fields in line $row: <br>";
|
||||
print "<p> $num fields in line $row: <br>";
|
||||
$row++;
|
||||
for ($c=0; $c<$num; $c++) {
|
||||
print $data[$c] . "<br>";
|
||||
for ($c=0; $c < $num; $c++) {
|
||||
print $data[$c] . "<br>";
|
||||
}
|
||||
}
|
||||
fclose ($fp);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -611,12 +625,14 @@ fclose ($fp);
|
|||
<example>
|
||||
<title>Reading a file line by line</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fd = fopen ("/tmp/inputfile.txt", "r");
|
||||
while (!feof ($fd)) {
|
||||
$buffer = fgets($fd, 4096);
|
||||
echo $buffer;
|
||||
}
|
||||
fclose ($fd);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -703,16 +719,18 @@ fclose ($fd);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// get a web page into an array and print it out
|
||||
$fcontents = file ('http://www.php.net');
|
||||
while (list ($line_num, $line) = each ($fcontents)) {
|
||||
echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n";
|
||||
echo "<b>Line $line_num:</b>; " . htmlspecialchars ($line) . "<br>\n";
|
||||
}
|
||||
|
||||
// get a web page into a string
|
||||
$fcontents = join ('', file ('http://www.php.net'));
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1266,10 +1284,12 @@ $fcontents = join ('', file ('http://www.php.net'));
|
|||
<example>
|
||||
<title><function>fopen</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fp = fopen ("/home/rasmus/file.txt", "r");
|
||||
$fp = fopen ("/home/rasmus/file.gif", "wb");
|
||||
$fp = fopen ("http://www.php.net/", "r");
|
||||
$fp = fopen ("ftp://user:password@example.com/", "w");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1284,7 +1304,9 @@ $fp = fopen ("ftp://user:password@example.com/", "w");
|
|||
used in the path to the file, or use forward slashes.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fp = fopen ("c:\\data\\info.txt", "r");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1392,11 +1414,13 @@ $fp = fopen ("c:\\data\\info.txt", "r");
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// get contents of a file into a string
|
||||
$filename = "/usr/local/something.txt";
|
||||
$fd = fopen ($filename, "r");
|
||||
$contents = fread ($fd, filesize ($filename));
|
||||
fclose ($fd);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1410,10 +1434,12 @@ fclose ($fd);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$filename = "c:\\files\\somepic.gif";
|
||||
$fd = fopen ($filename, "rb");
|
||||
$contents = fread ($fd, filesize ($filename));
|
||||
fclose ($fd);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1457,21 +1483,25 @@ fclose ($fd);
|
|||
<example>
|
||||
<title><function>fscanf</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fp = fopen ("users.txt","r");
|
||||
while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {
|
||||
list ($name, $profession, $countrycode) = $userinfo;
|
||||
//... do something with the values
|
||||
}
|
||||
fclose($fp);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>users.txt</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
javier argonaut pe
|
||||
hiroshi sculptor jp
|
||||
robert slacker us
|
||||
luigi florist it
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1730,12 +1760,14 @@ luigi florist it
|
|||
<example>
|
||||
<title><function>set_file_buffer</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fp=fopen($file, "w");
|
||||
if($fp){
|
||||
set_file_buffer($fp, 0);
|
||||
fputs($fp, $output);
|
||||
fclose($fp);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2101,7 +2133,9 @@ if($fp){
|
|||
can change using <function>umask</function>.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
mkdir ("/path/to/my/dir", 0700);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -2216,6 +2250,7 @@ mkdir ("/path/to/my/dir", 0700);
|
|||
<example>
|
||||
<title>Contents of sample.ini</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
; This is a sample configuration file
|
||||
; Comments start with ';', as in php.ini
|
||||
|
||||
|
@ -2225,6 +2260,7 @@ five = 5
|
|||
|
||||
[second_section]
|
||||
path = /usr/local/bin
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2252,6 +2288,7 @@ print_r($ini_array);
|
|||
Would produce:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[one] => 1
|
||||
|
@ -2272,6 +2309,7 @@ Array
|
|||
)
|
||||
|
||||
)
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -2302,7 +2340,8 @@ Array
|
|||
<example>
|
||||
<title><function>pathinfo</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$path_parts = pathinfo("/www/htdocs/index.html");
|
||||
|
||||
|
@ -2310,7 +2349,8 @@ echo $path_parts["dirname"] . "\n";
|
|||
echo $path_parts["basename"] . "\n";
|
||||
echo $path_parts["extension"] . "\n";
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2318,9 +2358,11 @@ echo $path_parts["extension"] . "\n";
|
|||
Would produce:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
/www/htdocs
|
||||
index.html
|
||||
html
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -2395,7 +2437,9 @@ html
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fp = popen ("/bin/ls", "r");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -2699,7 +2743,9 @@ $fp = popen ("/bin/ls", "r");
|
|||
<example>
|
||||
<title><function>realpath</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$real_path = realpath ("../../index.php");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2773,7 +2819,9 @@ $real_path = realpath ("../../index.php");
|
|||
<example>
|
||||
<title><function>tempnam</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$tmpfname = tempnam ("/tmp", "FOO");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2854,12 +2902,14 @@ $tmpfname = tempnam ("/tmp", "FOO");
|
|||
<example>
|
||||
<title><function>touch</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (touch ($FileName)) {
|
||||
print "$FileName modification time has been
|
||||
changed to todays date and time";
|
||||
} else {
|
||||
print "Sorry Could Not change modification time of $FileName";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.26 $ -->
|
||||
<!-- $Revision: 1.27 $ -->
|
||||
<reference id="ref.ftp">
|
||||
<title>FTP functions</title>
|
||||
<titleabbrev>FTP</titleabbrev>
|
||||
|
@ -26,7 +26,8 @@
|
|||
<example>
|
||||
<title><function>ftp</function> example</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// set up basic connection
|
||||
$conn_id = ftp_connect("$ftp_server");
|
||||
|
||||
|
@ -55,6 +56,7 @@ if (!$upload) {
|
|||
// close the FTP stream
|
||||
ftp_quit($conn_id);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -401,7 +403,9 @@ ftp_quit($conn_id);
|
|||
<example>
|
||||
<title><function>ftp_put</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$upload = ftp_put ($conn_id, "$destination_file", "$source_file", FTP_ASCII);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.19 $ -->
|
||||
<!-- $Revision: 1.20 $ -->
|
||||
<reference id="ref.funchand">
|
||||
<title>Function Handling functions</title>
|
||||
<titleabbrev>Functions</titleabbrev>
|
||||
|
@ -40,6 +40,7 @@
|
|||
For example:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function debug($var, $val)
|
||||
echo "***DEBUGGING\nVARIABLE: $var\nVALUE:";
|
||||
if (is_array($val) || is_object($val) || is_resource($val))
|
||||
|
@ -55,6 +56,7 @@ $host = $HTTP_SERVER_VARS["SERVER_NAME"];
|
|||
call_user_func_array ('debug', array("host", $host));
|
||||
call_user_func_array ('debug', array("c", $c));
|
||||
call_user_func_array ('debug', array("HTTP_POST_VARS", $HTTP_POST_VARS));
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -103,11 +105,13 @@ call_user_func_array ('debug', array("HTTP_POST_VARS", $HTTP_POST_VARS));
|
|||
following:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function barber ($type) {
|
||||
print "You wanted a $type haircut, no problem";
|
||||
}
|
||||
call_user_func ('barber', "mushroom");
|
||||
call_user_func ('barber', "shave");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -153,12 +157,14 @@ call_user_func ('barber', "shave");
|
|||
Creating an anonymous function with <function>create_function</function>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$newfunc = create_function('$a,$b','return "ln($a) + ln($b) = ".log($a * $b);');
|
||||
echo "New anonymous function: $newfunc\n";
|
||||
echo $newfunc(2,M_E)."\n";
|
||||
// outputs
|
||||
// New anonymous function: lambda_1
|
||||
// ln(2) + ln(2.718281828459) = 1.6931471805599
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
Or, perhaps to have general handler function that can apply a set
|
||||
|
@ -169,15 +175,16 @@ echo $newfunc(2,M_E)."\n";
|
|||
<function>create_function</function>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<."\n";
|
||||
}
|
||||
|
||||
// create a bunch of math functions
|
||||
$f1 = 'if ($a >=0) {return "b*a^2 = ".$b*sqrt($a);} else {return false;}';
|
||||
$f1 = 'if ($a >=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);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
and when you run the code above, the output will be:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Using the first array of anonymous functions
|
||||
parameters: 2.3445, M_PI
|
||||
some trig: -1.6291725057799
|
||||
|
@ -217,6 +226,7 @@ Using the second array of anonymous functions
|
|||
** Look the same to me! (looking at the first 3 chars)
|
||||
CRCs: -725381282 , 1908338681
|
||||
similar(a,b) = 11(45.833333333333%)
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
But perhaps the most common use for of lambda-style (anonymous) functions
|
||||
|
@ -225,16 +235,17 @@ similar(a,b) = 11(45.833333333333%)
|
|||
<example>
|
||||
<title>Using anonymous functions as callback functions</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$av = array("the ","a ","that ","this ");
|
||||
array_walk($av, create_function('&$v,$k','$v = $v."mango";'));
|
||||
print_r($av); // for PHP 3 use var_dump()
|
||||
// outputs:
|
||||
// Array
|
||||
// (
|
||||
// [0] => the mango
|
||||
// [1] => a mango
|
||||
// [2] => that mango
|
||||
// [3] => this mango
|
||||
// [0] => 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
|
||||
// )
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -294,17 +306,19 @@ print_r($sv);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo() {
|
||||
$numargs = func_num_args();
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
foo (1, 2, 3);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -346,21 +360,23 @@ foo (1, 2, 3);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo() {
|
||||
$numargs = func_num_args();
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\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] . "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
foo (1, 2, 3);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -402,14 +418,16 @@ foo (1, 2, 3);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo() {
|
||||
$numargs = func_num_args();
|
||||
echo "Number of arguments: $numargs\n";
|
||||
}
|
||||
|
||||
foo (1, 2, 3); // Prints 'Number of arguments: 3'
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -448,11 +466,13 @@ foo (1, 2, 3); // Prints 'Number of arguments: 3'
|
|||
function name was found, &false; otherwise.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (function_exists('imap_open')) {
|
||||
echo "IMAP functions are available.<br>\n";
|
||||
echo "IMAP functions are available.<br>\n";
|
||||
} else {
|
||||
echo "IMAP functions are not available.<br>\n";
|
||||
echo "IMAP functions are not available.<br>\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
Note that a function name may exist, even if the function itself
|
||||
|
@ -487,8 +507,9 @@ if (function_exists('imap_open')) {
|
|||
<varname>$arr["user"]</varname> (see example below).
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function myrow($id, $data) {
|
||||
return "<tr><th>$id</th><td>$data</td></tr>\n";
|
||||
return "<tr><th>$id</th><td>$data</td></tr>\n";
|
||||
}
|
||||
|
||||
$arr = get_defined_functions();
|
||||
|
@ -503,26 +524,27 @@ print_r($arr);
|
|||
<programlisting>
|
||||
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
|
||||
)
|
||||
|
||||
)
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<reference id="ref.gettext">
|
||||
<title>Gettext</title>
|
||||
<titleabbrev>gettext</titleabbrev>
|
||||
|
@ -96,7 +96,8 @@
|
|||
<example>
|
||||
<title><function>gettext</function>-check</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Set language to German
|
||||
putenv ("LANG=de");
|
||||
|
||||
|
@ -109,6 +110,7 @@ textdomain ("myPHPApp");
|
|||
// Print a test message
|
||||
print (gettext ("Welcome to My PHP Application"));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<reference id="ref.gmp">
|
||||
<title>GMP functions</title>
|
||||
<titleabbrev>GMP</titleabbrev>
|
||||
|
@ -51,7 +51,8 @@
|
|||
<example>
|
||||
<title>Factorial function using GMP</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
function fact ($x) {
|
||||
if ($x <= 1)
|
||||
return 1;
|
||||
|
@ -60,7 +61,8 @@ function fact ($x) {
|
|||
}
|
||||
|
||||
print gmp_strval (fact (1000)) . "\n";
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -92,10 +94,12 @@ print gmp_strval (fact (1000)) . "\n";
|
|||
<example>
|
||||
<title>Creating GMP number</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = gmp_init (123456);
|
||||
$b = gmp_init ("0xFFFFDEBACDFEDF7200");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -164,10 +168,12 @@ print gmp_strval (fact (1000)) . "\n";
|
|||
<example>
|
||||
<title>Converting a GMP number to a string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = gmp_init("0x41682179fbf5");
|
||||
printf ("Decimal: %s, 36-based: %s", gmp_strval($a), gmp_strval($a,36));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -356,12 +362,14 @@ print gmp_strval (fact (1000)) . "\n";
|
|||
<example>
|
||||
<title>Division of GMP numbers</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = gmp_init ("0x41682179fbf5");
|
||||
$res = gmp_div_qr ($a, "0xDEFE75");
|
||||
printf("Result is: q - %s, r - %s",
|
||||
gmp_strval ($res[0]), gmp_strval ($res[1]));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.32 $ -->
|
||||
<!-- $Revision: 1.33 $ -->
|
||||
<reference id="ref.http">
|
||||
<title>HTTP functions</title>
|
||||
<titleabbrev>HTTP</titleabbrev>
|
||||
|
@ -39,8 +39,10 @@
|
|||
multiple headers of the same type. For example:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
header('WWW-Authenticate: Negotiate');
|
||||
header('WWW-Authenticate: NTLM',false);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -51,10 +53,12 @@ header('WWW-Authenticate: NTLM',false);
|
|||
(302) status code to the browser.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
header("Location: http://www.php.net/"); /* Redirect browser
|
||||
to PHP web site */
|
||||
exit; /* Make sure that code below does
|
||||
not get executed when we redirect. */
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -69,9 +73,11 @@ exit; /* Make sure that code below does
|
|||
relative one yourself:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
header("Location: http://".$HTTP_SERVER_VARS['HTTP_HOST']
|
||||
."/".dirname($HTTP_SERVER_VARS['PHP_SELF'])
|
||||
."/".$relative_url);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -86,7 +92,9 @@ header("Location: http://".$HTTP_SERVER_VARS['HTTP_HOST']
|
|||
make sure that your script generates the proper status code.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<note>
|
||||
|
@ -96,7 +104,9 @@ header("HTTP/1.0 404 Not Found");
|
|||
<literal>Status</literal> header.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
header("Status: 404 Not Found");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -109,12 +119,14 @@ header("Status: 404 Not Found");
|
|||
caching with
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
// always modified
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<note>
|
||||
|
@ -145,11 +157,13 @@ header("Pragma: no-cache"); // HTTP/1.0
|
|||
when using a single PHP/HTML file.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php require("user_logging.inc") ?>
|
||||
<![CDATA[
|
||||
<?php require("user_logging.inc") ?>
|
||||
|
||||
|
||||
<?php header ("Content-type: audio/x-pn-realaudio"); ?>
|
||||
<?php header ("Content-type: audio/x-pn-realaudio"); ?>
|
||||
// Broken, Note the blank lines above
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<note>
|
||||
|
@ -172,11 +186,13 @@ header("Pragma: no-cache"); // HTTP/1.0
|
|||
save dialog.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
header("Content-type: application/pdf");
|
||||
header("Content-Disposition: attachment; filename=downloaded.pdf");
|
||||
|
||||
/* ... output pdf file ... */
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<note>
|
||||
|
@ -299,9 +315,11 @@ header("Content-Disposition: attachment; filename=downloaded.pdf");
|
|||
<example>
|
||||
<title><function>setcookie</function> send examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
setcookie ("TestCookie", "Test Value");
|
||||
setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */
|
||||
setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -310,10 +328,12 @@ setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
|
|||
<example>
|
||||
<title><function>setcookie</function> delete examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
setcookie ("TestCookie");
|
||||
// set the expiration date to one hour ago
|
||||
setcookie ("TestCookie", "", time() - 3600);
|
||||
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
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:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo $TestCookie;
|
||||
echo $HTTP_COOKIE_VARS["TestCookie"];
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -340,14 +362,16 @@ echo $HTTP_COOKIE_VARS["TestCookie"];
|
|||
name:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
setcookie ("cookie[three]", "cookiethree");
|
||||
setcookie ("cookie[two]", "cookietwo");
|
||||
setcookie ("cookie[one]", "cookieone");
|
||||
if (isset ($cookie)) {
|
||||
while (list ($name, $value) = each ($cookie)) {
|
||||
echo "$name == $value<br>\n";
|
||||
echo "$name == $value<br>\n";
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.20 $ -->
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<reference id="ref.hyperwave">
|
||||
<title>Hyperwave functions</title>
|
||||
<titleabbrev>Hyperwave</titleabbrev>
|
||||
|
@ -282,9 +282,13 @@
|
|||
<systemitem role="url">http://your.hostname/name_of_object</systemitem> would
|
||||
return the object. The rewriting rule is quite easy:
|
||||
|
||||
<informalexample><programlisting role="apache-conf">
|
||||
<informalexample>
|
||||
<programlisting role="apache-conf">
|
||||
<![CDATA[
|
||||
RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$1 [L]
|
||||
</programlisting></informalexample>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
||||
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:
|
||||
|
||||
<informalexample><programlisting role="apache-conf">
|
||||
<informalexample>
|
||||
<programlisting role="apache-conf">
|
||||
<![CDATA[
|
||||
RewriteRule ^/hw/(.*) /usr/local/apache/htdocs/hw/$1 [L]
|
||||
</programlisting></informalexample>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
||||
This will reserve the directory <filename class="directory">/usr/local/apache/htdocs/hw</filename> 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
|
||||
|
||||
<informalexample><programlisting role="apache-conf">
|
||||
<informalexample>
|
||||
<programlisting role="apache-conf">
|
||||
<![CDATA[
|
||||
RewriteEngine on
|
||||
</programlisting></informalexample>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
||||
My experiences have shown that you will need the following
|
||||
scripts:
|
||||
|
@ -1707,11 +1719,13 @@ RewriteEngine on
|
|||
<example>
|
||||
<title>modifying an attribute</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $connect is an existing connection to the Hyperwave server
|
||||
// $objid is the ID of the object to modify
|
||||
$remarr = array("Name" => "books");
|
||||
$addarr = array("Name" => "articles");
|
||||
$hw_modifyobject($connect, $objid, $remarr, $addarr);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
In order to delete/add a name=value pair from/to the object record just
|
||||
|
@ -1721,11 +1735,13 @@ RewriteEngine on
|
|||
<example>
|
||||
<title>adding a completely new attribute</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $connect is an existing connection to the Hyperwave server
|
||||
// $objid is the ID of the object to modify
|
||||
$remarr = array("Name" => 0);
|
||||
$addarr = array("Name" => "articles");
|
||||
$hw_modifyobject($connect, $objid, $remarr, $addarr);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1742,18 +1758,22 @@ RewriteEngine on
|
|||
<example>
|
||||
<title>modifying Title attribute</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$remarr = array("Title" => "en:Books");
|
||||
$addarr = array("Title" => "en:Articles");
|
||||
$hw_modifyobject($connect, $objid, $remarr, $addarr);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
or
|
||||
<example>
|
||||
<title>modifying Title attribute</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$remarr = array("Title" => array("en" => "Books"));
|
||||
$addarr = array("Title" => array("en" => "Articles", "ge"=>"Artikel"));
|
||||
$hw_modifyobject($connect, $objid, $remarr, $addarr);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
This removes the english title 'Books' and adds the english title
|
||||
|
@ -1761,9 +1781,11 @@ RewriteEngine on
|
|||
<example>
|
||||
<title>removing attribute</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$remarr = array("Title" => "");
|
||||
$addarr = array("Title" => "en:Articles");
|
||||
$hw_modifyobject($connect, $objid, $remarr, $addarr);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.32 $ -->
|
||||
<!-- $Revision: 1.33 $ -->
|
||||
<reference id="ref.ibase">
|
||||
<title>InterBase functions</title>
|
||||
<titleabbrev>InterBase</titleabbrev>
|
||||
|
@ -21,7 +21,9 @@
|
|||
<filename>php.ini</filename> the following directive:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
magic_quotes_sybase = On
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -87,7 +89,8 @@ magic_quotes_sybase = On
|
|||
<example>
|
||||
<title><function>ibase_connect</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dbh = ibase_connect ($host, $username, $password);
|
||||
$stmt = 'SELECT * FROM tblname';
|
||||
$sth = ibase_query ($dbh, $stmt);
|
||||
|
@ -96,6 +99,7 @@ magic_quotes_sybase = On
|
|||
}
|
||||
ibase_close ($dbh);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -303,7 +307,8 @@ magic_quotes_sybase = On
|
|||
<function>ibase_execute</function>.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<php
|
||||
<![CDATA[
|
||||
<php
|
||||
$dbh = ibase_connect ($host, $username, $password);
|
||||
$stmt = 'SELECT * FROM tblname';
|
||||
$sth = ibase_query ($dbh, $stmt);
|
||||
|
@ -312,6 +317,7 @@ magic_quotes_sybase = On
|
|||
}
|
||||
ibase_close ($dbh);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -343,6 +349,7 @@ magic_quotes_sybase = On
|
|||
relation, length, type.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// helio@helio.com.br 08-Dec-2000 02:53
|
||||
|
||||
$rs=ibase_query("Select * from something");
|
||||
|
@ -355,6 +362,7 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
echo "length: ".$col_info['length']."\n";
|
||||
echo "type: ".$col_info['type']."\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -434,7 +442,8 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
some parameters changing.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$updates = array(
|
||||
1 => 'Eric',
|
||||
5 => 'Filip',
|
||||
|
@ -447,6 +456,7 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
ibase_execute($query, $bar, $baz);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -577,11 +587,13 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
defaults to IBASE_TIMESTAMP for backwards compatibility.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// InterBase 6 TIME-type columns will be returned in
|
||||
// the form '05 hours 37 minutes'.
|
||||
ibase_timefmt("%H hours %M minutes", IBASE_TIME);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -627,7 +639,8 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
set.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dbh = ibase_connect ($host, $username, $password);
|
||||
$stmt = 'SELECT * FROM tblname';
|
||||
$sth = ibase_query ($dbh, $stmt);
|
||||
|
@ -642,6 +655,7 @@ for ($i=0 ; $i < $coln ; $i++) {
|
|||
|
||||
ibase_close ($dbh);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<reference id="ref.iconv">
|
||||
<title>iconv functions</title>
|
||||
<titleabbrev>iconv</titleabbrev>
|
||||
|
@ -49,7 +49,9 @@
|
|||
<example>
|
||||
<title><function>iconv</function> example:</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo iconv("ISO-8859-1","UTF-8","This is test.");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -111,8 +113,10 @@ echo iconv("ISO-8859-1","UTF-8","This is test.");
|
|||
<example>
|
||||
<title><function>iconv_set_encoding</function> example:</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
iconv_set_encoding("internal_encoding", "UTF-8");
|
||||
iconv_set_encoding("output_encoding", "ISO-8859-1");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -159,7 +163,9 @@ iconv_set_encoding("output_encoding", "ISO-8859-1");
|
|||
<example>
|
||||
<title><function>ob_iconv_handler</function> example:</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
ob_start("ob_iconv_handler"); // start output buffering
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
<!-- $Revision: 1.23 $ -->
|
||||
<reference id="ref.ifx">
|
||||
<title>Informix functions</title>
|
||||
<titleabbrev>Informix</titleabbrev>
|
||||
|
@ -212,8 +212,10 @@
|
|||
<function>ifx_close</function>.
|
||||
<example>
|
||||
<title>Connect to a Informix database</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$conn_id = ifx_connect ("mydb@ol_srv1", "imyself", "mypassword");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -310,10 +312,12 @@ $conn_id = ifx_connect ("mydb@ol_srv1", "imyself", "mypassword");
|
|||
<function>ifx_pconnect</function>.
|
||||
<example>
|
||||
<title>Closing a Informix connection</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$conn_id = ifx_connect ("mydb@ol_srv", "itsme", "mypassword");
|
||||
... some queries and stuff ...
|
||||
ifx_close($conn_id);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -401,22 +405,25 @@ ifx_close($conn_id);
|
|||
<title>
|
||||
Show all rows of the "orders" table as a html table
|
||||
</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
ifx_textasvarchar(1); // use "text mode" for blobs
|
||||
$res_id = ifx_query("select * from orders", $conn_id);
|
||||
if (! $res_id) {
|
||||
printf("Can't select orders : %s\n<br>%s<br>\n", ifx_error());
|
||||
printf("Can't select orders : %s\n<br>%s<br>\n", ifx_error());
|
||||
ifx_errormsg();
|
||||
die;
|
||||
}
|
||||
ifx_htmltbl_result($res_id, "border=\"1\"");
|
||||
ifx_free_result($res_id);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Insert some values into the "catalog" table</title>
|
||||
<programlisting role="php3">
|
||||
// create blob id's for a byte and text column
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// create blob id's for a byte and text column
|
||||
$textid = ifx_create_blob(0, 0, "Text column in memory");
|
||||
$byteid = ifx_create_blob(1, 0, "Byte column in memory");
|
||||
// store blob id's in a blobid array
|
||||
|
@ -431,6 +438,7 @@ if (! $res_id) {
|
|||
}
|
||||
// free result id
|
||||
ifx_free_result($res_id);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -618,8 +626,10 @@ ifx_free_result($res_id);
|
|||
See also: <function>ifx_error</function>
|
||||
</para>
|
||||
<informalexample>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
printf("%s\n<br>", ifx_errormsg(-201));
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</refsect1>
|
||||
|
@ -665,7 +675,8 @@ printf("%s\n<br>", ifx_errormsg(-201));
|
|||
</para>
|
||||
<example>
|
||||
<title>Informix affected rows</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$rid = ifx_prepare ("select * from emp
|
||||
where name like " . $name, $connid);
|
||||
if (! $rid) {
|
||||
|
@ -673,9 +684,10 @@ if (! $rid) {
|
|||
}
|
||||
$rowcount = ifx_affected_rows ($rid);
|
||||
if ($rowcount > 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<br>", $rowcount);
|
||||
die ("Please restrict your query<br>\n");
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -719,7 +731,8 @@ if ($rowcount > 1000) {
|
|||
</para>
|
||||
<example>
|
||||
<title>Retrieve Informix sqlca.sqlerrd[x] values</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* assume the first column of 'sometable' is a serial */
|
||||
$qid = ifx_query("insert into sometable
|
||||
values (0, '2nd column', 'another column') ", $connid);
|
||||
|
@ -728,7 +741,8 @@ if (! $qid) {
|
|||
}
|
||||
$sqlca = ifx_getsqlca ($qid);
|
||||
$serial_value = $sqlca["sqlerrd1"];
|
||||
echo "The serial value of the inserted row is : " . $serial_value<br>\n";
|
||||
echo "The serial value of the inserted row is : " . $serial_value<br>\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -785,7 +799,8 @@ echo "The serial value of the inserted row is : " . $serial_value<br>\n";
|
|||
</para>
|
||||
<example>
|
||||
<title>Informix fetch rows</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$rid = ifx_prepare ("select * from emp where name like " . $name,
|
||||
$connid, IFX_SCROLL);
|
||||
if (! $rid) {
|
||||
|
@ -793,8 +808,8 @@ if (! $rid) {
|
|||
}
|
||||
$rowcount = ifx_affected_rows($rid);
|
||||
if ($rowcount > 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<br>", $rowcount);
|
||||
die ("Please restrict your query<br>\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<br>");
|
||||
$row = ifx_fetch_row ($rid, "NEXT");
|
||||
}
|
||||
ifx_free_result ($rid);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -842,7 +858,8 @@ ifx_free_result ($rid);
|
|||
</para>
|
||||
<example>
|
||||
<title>Informix results as HTML table</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$rid = ifx_prepare ("select * from emp where name like " . $name,
|
||||
$connid, IFX_SCROLL);
|
||||
if (! $rid) {
|
||||
|
@ -850,8 +867,8 @@ if (! $rid) {
|
|||
}
|
||||
$rowcount = ifx_affected_rows ($rid);
|
||||
if ($rowcount > 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<br>", $rowcount);
|
||||
die ("Please restrict your query<br>\n");
|
||||
}
|
||||
if (! ifx_do($rid) {
|
||||
... error ...
|
||||
|
@ -860,6 +877,7 @@ if (! ifx_do($rid) {
|
|||
ifx_htmltbl_result ($rid, "border=\"2\"");
|
||||
|
||||
ifx_free_result($rid);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -885,16 +903,18 @@ ifx_free_result($rid);
|
|||
</para>
|
||||
<example>
|
||||
<title>Fielnames and SQL fieldtypes</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$types = ifx_fieldtypes ($resultid);
|
||||
if (! isset ($types)) {
|
||||
... error ...
|
||||
}
|
||||
for ($i = 0; $i < count($types); $i++) {
|
||||
for ($i = 0; $i < count($types); $i++) {
|
||||
$fname = key($types);
|
||||
printf("%s :\t type = %s\n", $fname, $types[$fname]);
|
||||
next($types);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -926,16 +946,18 @@ for ($i = 0; $i < count($types); $i++) {
|
|||
</para>
|
||||
<example>
|
||||
<title>Informix SQL fieldproperties</title>
|
||||
<programlisting role="php3">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$properties = ifx_fieldproperties ($resultid);
|
||||
if (! isset($properties)) {
|
||||
... error ...
|
||||
}
|
||||
for ($i = 0; $i < count($properties); $i++) {
|
||||
for ($i = 0; $i < count($properties); $i++) {
|
||||
$fname = key ($properties);
|
||||
printf ("%s:\t type = %s\n", $fname, $properties[$fname]);
|
||||
next ($properties);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.61 $ -->
|
||||
<!-- $Revision: 1.62 $ -->
|
||||
<reference id="ref.image">
|
||||
<title>Image functions</title>
|
||||
<titleabbrev>Image</titleabbrev>
|
||||
|
@ -69,8 +69,10 @@
|
|||
<example>
|
||||
<title>GetImageSize (file)</title>
|
||||
<programlisting role="php">
|
||||
<?php $size = GetImageSize ("img/flag.jpg"); ?>
|
||||
<IMG SRC="img/flag.jpg" <?php echo $size[3]; ?>
|
||||
<![CDATA[
|
||||
<?php $size = GetImageSize ("img/flag.jpg"); ?>
|
||||
<IMG SRC="img/flag.jpg" <?php echo $size[3]; ?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -78,7 +80,9 @@
|
|||
<example>
|
||||
<title>GetImageSize (URL)</title>
|
||||
<programlisting role="php">
|
||||
<?php $size = GetImageSize ("http://www.php.net/gifs/logo.gif"); ?>
|
||||
<![CDATA[
|
||||
<?php $size = GetImageSize ("http://www.php.net/gifs/logo.gif"); ?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -107,13 +111,15 @@
|
|||
<example>
|
||||
<title>GetImageSize returning IPTC</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$size = GetImageSize ("testimg.jpg",&$info);
|
||||
if (isset ($info["APP13"])) {
|
||||
$iptc = iptcparse ($info["APP13"]);
|
||||
var_dump ($iptc);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -447,8 +453,10 @@
|
|||
by <parameter>im</parameter>.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$white = ImageColorAllocate ($im, 255, 255, 255);
|
||||
$black = ImageColorAllocate ($im, 0, 0, 0);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -483,8 +491,10 @@ $black = ImageColorAllocate ($im, 0, 0, 0);
|
|||
<function>ImageColorAllocate</function> function.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$white = ImageColorAllocate($im, 255, 255, 255);
|
||||
ImageColorDeAllocate($im, $white);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1103,7 +1113,8 @@ ImageColorDeAllocate($im, $white);
|
|||
Creating a new GD image stream and outputting an image.
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
header ("Content-type: image/png");
|
||||
$im = @ImageCreate (50, 100)
|
||||
or die ("Cannot Initialize new GD image stream");
|
||||
|
@ -1112,6 +1123,7 @@ $text_color = ImageColorAllocate ($im, 233, 14, 91);
|
|||
ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color);
|
||||
ImagePng ($im);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1210,6 +1222,7 @@ ImagePng ($im);
|
|||
vic@zymsys.com)
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function LoadGif ($imgname) {
|
||||
$im = @ImageCreateFromGIF ($imgname); /* Attempt to open */
|
||||
if (!$im) { /* See if it failed */
|
||||
|
@ -1222,6 +1235,7 @@ function LoadGif ($imgname) {
|
|||
}
|
||||
return $im;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -1263,6 +1277,7 @@ function LoadGif ($imgname) {
|
|||
vic@zymsys.com )
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function LoadJpeg ($imgname) {
|
||||
$im = @ImageCreateFromJPEG ($imgname); /* Attempt to open */
|
||||
if (!$im) { /* See if it failed */
|
||||
|
@ -1275,6 +1290,7 @@ function LoadJpeg ($imgname) {
|
|||
}
|
||||
return $im;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1309,6 +1325,7 @@ function LoadJpeg ($imgname) {
|
|||
vic@zymsys.com)
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function LoadPNG ($imgname) {
|
||||
$im = @ImageCreateFromPNG ($imgname); /* Attempt to open */
|
||||
if (!$im) { /* See if it failed */
|
||||
|
@ -1321,6 +1338,7 @@ function LoadPNG ($imgname) {
|
|||
}
|
||||
return $im;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1355,6 +1373,7 @@ function LoadPNG ($imgname) {
|
|||
vic@zymsys.com)
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
function LoadWBMP ($imgname) {
|
||||
$im = @ImageCreateFromWBMP ($imgname); /* Attempt to open */
|
||||
if (!$im) { /* See if it failed */
|
||||
|
@ -1367,6 +1386,7 @@ function LoadWBMP ($imgname) {
|
|||
}
|
||||
return $im;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -1689,7 +1709,8 @@ function LoadWBMP ($imgname) {
|
|||
ImageGIF($im);</literal> by the more flexible sequence:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
if (function_exists("imagegif")) {
|
||||
Header("Content-type: image/gif");
|
||||
ImageGIF($im);
|
||||
|
@ -1708,7 +1729,8 @@ function LoadWBMP ($imgname) {
|
|||
}
|
||||
else
|
||||
die("No image support in this PHP server");
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1721,12 +1743,15 @@ function LoadWBMP ($imgname) {
|
|||
the presence of the various supported image formats:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (ImageTypes() & IMG_GIF) {
|
||||
Header("Content-type: image/gif");
|
||||
ImageGif($im);
|
||||
}
|
||||
elseif (ImageTypes() & IMG_JPG) {
|
||||
... etc.</programlisting>
|
||||
... etc.
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
</note>
|
||||
|
@ -1763,10 +1788,12 @@ elseif (ImageTypes() & IMG_JPG) {
|
|||
<parameter>filename</parameter> it outputs the image to the file.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$im = ImageCreateFromPng("test.png");
|
||||
ImagePng($im);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -2284,7 +2311,8 @@ ImagePng($im);
|
|||
</para>
|
||||
<para>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
Header ("Content-type: image/jpeg");
|
||||
$im = ImageCreate (350, 45);
|
||||
$black = ImageColorAllocate ($im, 0, 0, 0);
|
||||
|
@ -2296,7 +2324,8 @@ $font, 32, $white, $black, 32, 32);
|
|||
ImagePsFreeFont($font);
|
||||
ImageJpeg($im, "", 100);//for best quality... your mileage may vary
|
||||
ImageDestroy ($im);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
|
@ -2603,7 +2632,8 @@ ImageDestroy ($im);
|
|||
<example>
|
||||
<title>ImageSetStyle</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
Header ("Content-type: image/png");
|
||||
$im = imagecreate (100, 100);
|
||||
$w = ImageColorAllocate ($im, 255, 255, 255);
|
||||
|
@ -2625,7 +2655,8 @@ ImageLine($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);
|
|||
|
||||
ImagePng($im);
|
||||
ImageDestroy ($im);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2993,7 +3024,8 @@ ImageDestroy ($im);
|
|||
<example>
|
||||
<title>ImageTTFText</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
Header ("Content-type: image/gif");
|
||||
$im = imagecreate (400, 30);
|
||||
$black = ImageColorAllocate ($im, 0, 0, 0);
|
||||
|
@ -3002,7 +3034,8 @@ ImageTTFText ($im, 20, 0, 10, 20, $white, "/path/arial.ttf",
|
|||
"Testing... Omega: &#937;");
|
||||
ImageGif ($im);
|
||||
ImageDestroy ($im);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -3039,11 +3072,13 @@ ImageDestroy ($im);
|
|||
<example>
|
||||
<title>ImageTypes</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
if (ImageTypes() & IMG_PNG) {
|
||||
echo "PNG Support is enabled";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -3153,10 +3188,11 @@ if (ImageTypes() & IMG_PNG) {
|
|||
<example>
|
||||
<title>read_exif_data</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$exif = read_exif_data ('p0001807.jpg');
|
||||
while(list($k,$v)=each($exif)) {
|
||||
echo "$k: $v<br>\n";
|
||||
echo "$k: $v<br>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -3181,6 +3217,7 @@ FocusDistance: 16.66m
|
|||
RawFocusDistance: 16.659999847412
|
||||
Orientation: 1
|
||||
ExifVersion: 0200
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.52 $ -->
|
||||
<!-- $Revision: 1.53 $ -->
|
||||
<reference id='ref.imap'>
|
||||
<title>IMAP, POP3 and NNTP functions</title>
|
||||
<titleabbrev>IMAP</titleabbrev>
|
||||
|
@ -180,6 +180,7 @@
|
|||
<example>
|
||||
<title><function>imap_append</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$stream = imap_open("{your.imap.host}INBOX.Drafts","username", "password");
|
||||
|
||||
$check = imap_check($stream);
|
||||
|
@ -197,6 +198,7 @@ $check = imap_check($stream);
|
|||
print "Msg Count after append : ". $check->Nmsgs."\n";
|
||||
|
||||
imap_close($stream);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -454,6 +456,7 @@ ST_UID The sequence argument contains UIDs instead of
|
|||
<example>
|
||||
<title><function>imap_createmailbox</function> example</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -462,7 +465,7 @@ $name2 = imap_utf7_encode("phpnewböx");
|
|||
|
||||
$newname = $name1;
|
||||
|
||||
echo "Newname will be '$name1'<br>\n";
|
||||
echo "Newname will be '$name1'<br>\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:<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";
|
||||
|
||||
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'<br>\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()."<br>\n";
|
||||
}
|
||||
} else {
|
||||
print "imap_status on new mailbox failed: ".imap_last_error()."<br>\n";
|
||||
print "imap_status on new mailbox failed: ".imap_last_error()."<br>\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<br>\n";
|
||||
} else {
|
||||
print "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n";
|
||||
print "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
print "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n";
|
||||
print "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n";
|
||||
}
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -541,18 +545,20 @@ imap_close($mbox);
|
|||
<example>
|
||||
<title><function>imap_delete</function> Beispiel</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{your.imap.host}INBOX", "username", "password")
|
||||
or die ("can't connect: " . imap_last_error());
|
||||
|
||||
$check = imap_mailboxmsginfo ($mbox);
|
||||
print "Messages before delete: " . $check->Nmsgs . "<br>\n" ;
|
||||
print "Messages before delete: " . $check->Nmsgs . "<br>\n" ;
|
||||
imap_delete ($mbox, 1);
|
||||
$check = imap_mailboxmsginfo ($mbox);
|
||||
print "Messages after delete: " . $check->Nmsgs . "<br>\n" ;
|
||||
print "Messages after delete: " . $check->Nmsgs . "<br>\n" ;
|
||||
imap_expunge ($mbox);
|
||||
$check = imap_mailboxmsginfo ($mbox);
|
||||
print "Messages after expunge: " . $check->Nmsgs . "<br>\n" ;
|
||||
print "Messages after expunge: " . $check->Nmsgs . "<br>\n" ;
|
||||
imap_close ($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -744,6 +750,7 @@ imap_close ($mbox);
|
|||
<example>
|
||||
<title><function>imap_fetch_overview</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host:143}","username","password")
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -760,6 +767,7 @@ if(is_array($overview)) {
|
|||
}
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1072,6 +1080,7 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
|
|||
<example>
|
||||
<title><function>imap_get_quota</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host}","mailadmin","password",OP_HALFOPEN)
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -1082,6 +1091,7 @@ if(is_array($quota_value)) {
|
|||
}
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1170,6 +1180,7 @@ imap_close($mbox);
|
|||
<example>
|
||||
<title><function>imap_getmailboxes</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -1181,12 +1192,13 @@ if(is_array($list)) {
|
|||
print "($key) ";
|
||||
print imap_utf7_decode($val->name).",";
|
||||
print "'".$val->delimiter."',";
|
||||
print $val->attributes."<br>\n";
|
||||
print $val->attributes."<br>\n";
|
||||
}
|
||||
} else
|
||||
print "imap_getmailboxes failed: ".imap_last_error()."\n";
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1442,6 +1454,7 @@ fetchsubject (subject line formatted to fit <parameter>subjectlength</parameter>
|
|||
<example>
|
||||
<title><function>imap_listmailbox</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -1449,11 +1462,12 @@ $list = imap_listmailbox($mbox,"{your.imap.host}","*");
|
|||
if(is_array($list)) {
|
||||
reset($list);
|
||||
while (list($key, $val) = each($list))
|
||||
print imap_utf7_decode($val)."<br>\n";
|
||||
print imap_utf7_decode($val)."<br>\n";
|
||||
} else
|
||||
print "imap_listmailbox failed: ".imap_last_error()."\n";
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1544,7 +1558,8 @@ imap_close($mbox);
|
|||
<example>
|
||||
<title><function>imap_mail_compose</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$envelope["from"]="musone@afterfive.com";
|
||||
$envelope["to"]="musone@darkstar";
|
||||
|
@ -1575,7 +1590,8 @@ $body[3]=$part3;
|
|||
|
||||
echo nl2br(imap_mail_compose($envelope,$body));
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1738,7 +1754,8 @@ echo nl2br(imap_mail_compose($envelope,$body));
|
|||
<example>
|
||||
<title><function>imap_mailboxmsginfo</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$mbox = imap_open("{your.imap.host}INBOX","username", "password")
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
@ -1746,21 +1763,22 @@ $mbox = imap_open("{your.imap.host}INBOX","username", "password")
|
|||
$check = imap_mailboxmsginfo($mbox);
|
||||
|
||||
if($check) {
|
||||
print "Date: " . $check->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 ."<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" ;
|
||||
} else {
|
||||
print "imap_check() failed: ".imap_last_error(). "<br>\n";
|
||||
print "imap_check() failed: ".imap_last_error(). "<br>\n";
|
||||
}
|
||||
|
||||
imap_close($mbox);
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1794,14 +1812,15 @@ imap_close($mbox);
|
|||
<example>
|
||||
<title><function>imap_mime_header_decode</function> example</title>
|
||||
<programlisting role="php">
|
||||
$text="=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>";
|
||||
<![CDATA[
|
||||
$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;$i<count($elements);$i++) {
|
||||
echo "Charset: {$elements[$i]->charset}\n";
|
||||
echo "Text: {$elements[$i]->text}\n\n";
|
||||
}
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1954,33 +1973,43 @@ for($i=0;$i<count($elements);$i++) {
|
|||
local machine, do the following:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{localhost:143}INBOX", "user_id", "password");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
To connect to a POP3 server on port 110 on the local server, use:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
|
||||
specification:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
To connect to an SSL IMAP or POP3 server with a self-signed
|
||||
certificate, add /ssl/novalidate-cert after the protocol specification:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
To connect to an NNTP server on port 119 on the local server, use:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
To connect to a remote server replace "localhost" with the name
|
||||
|
@ -1990,31 +2019,33 @@ $nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
|
|||
<example>
|
||||
<title><function>imap_open</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{your.imap.host:143}", "username", "password");
|
||||
|
||||
echo "<p><h1>Mailboxes</h1>\n";
|
||||
echo "<p><h1>Mailboxes</h1>\n";
|
||||
$folders = imap_listmailbox ($mbox, "{your.imap.host:143}", "*");
|
||||
|
||||
if ($folders == false) {
|
||||
echo "Call failed<br>\n";
|
||||
echo "Call failed<br>\n";
|
||||
} else {
|
||||
while (list ($key, $val) = each ($folders)) {
|
||||
echo $val."<br>\n";
|
||||
echo $val."<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<p><h1>Headers in INBOX</h1>\n";
|
||||
echo "<p><h1>Headers in INBOX</h1>\n";
|
||||
$headers = imap_headers ($mbox);
|
||||
|
||||
if ($headers == false) {
|
||||
echo "Call failed<br>\n";
|
||||
echo "Call failed<br>\n";
|
||||
} else {
|
||||
while (list ($key,$val) = each ($headers)) {
|
||||
echo $val."<br>\n";
|
||||
echo $val."<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2215,17 +2246,19 @@ imap_close($mbox);
|
|||
<example>
|
||||
<title><function>imap_rfc822_parse_adrlist</function> example</title>
|
||||
<programlisting role="php">
|
||||
$address_string = "Hartmut Holzgraefe <hartmut@cvs.php.net>, postmaster@somedomain.net, root";
|
||||
<![CDATA[
|
||||
$address_string = "Hartmut Holzgraefe <hartmut@cvs.php.net>, 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."<br>\n";
|
||||
print "host : ".$val->host."<br>\n";
|
||||
print "personal: ".$val->personal."<br>\n";
|
||||
print "adl : ".$val->adl."<p>\n";
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2285,7 +2318,9 @@ while(list($key,$val)=each($address_array)){
|
|||
<example>
|
||||
<title><function>imap_rfc822_write_address</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2527,6 +2562,7 @@ print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\
|
|||
<example>
|
||||
<title><function>imap_set_quota</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open ("{your.imap.host:143}", "mailadmin", "password");
|
||||
|
||||
if(!imap_set_quota($mbox, "user.kalowsky", 3000)) {
|
||||
|
@ -2535,6 +2571,7 @@ if(!imap_set_quota($mbox, "user.kalowsky", 3000)) {
|
|||
}
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2583,6 +2620,7 @@ ST_UID The sequence argument contains UIDs instead of
|
|||
<example>
|
||||
<title><function>imap_setflag_full</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host:143}","username","password")
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
|
@ -2592,6 +2630,7 @@ print gettype($status)."\n";
|
|||
print $status."\n";
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -2714,20 +2753,22 @@ SE_NOPREFETCH Don't prefetch searched messages.
|
|||
<example>
|
||||
<title><function>imap_status</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
|
||||
or die("can't connect: ".imap_last_error());
|
||||
|
||||
$status = imap_status($mbox,"{your.imap.host}INBOX",SA_ALL);
|
||||
if($status) {
|
||||
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("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";
|
||||
} else
|
||||
print "imap_status failed: ".imap_last_error()."\n";
|
||||
|
||||
imap_close($mbox);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.75 $ -->
|
||||
<!-- $Revision: 1.76 $ -->
|
||||
<reference id="ref.info">
|
||||
<title>PHP options & information</title>
|
||||
<titleabbrev>PHP options/info</titleabbrev>
|
||||
|
@ -72,7 +72,8 @@
|
|||
<example>
|
||||
<title>Handle a failed assertion with a custom handler</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Active assert and make it quiet
|
||||
assert_options (ASSERT_ACTIVE, 1);
|
||||
assert_options (ASSERT_WARNING, 0);
|
||||
|
@ -80,10 +81,10 @@ assert_options (ASSERT_QUIET_EVAL, 1);
|
|||
|
||||
// Create a handler function
|
||||
function my_assert_handler ($file, $line, $code) {
|
||||
echo "<hr>Assertion Failed:
|
||||
File '$file'<br>
|
||||
Line '$line'<br>
|
||||
Code '$code'<br><hr>";
|
||||
echo "<hr>Assertion Failed:
|
||||
File '$file'<br>
|
||||
Line '$line'<br>
|
||||
Code '$code'<br><hr>";
|
||||
}
|
||||
|
||||
// Set up the callback
|
||||
|
@ -91,7 +92,8 @@ assert_options (ASSERT_CALLBACK, 'my_assert_handler');
|
|||
|
||||
// Make an assertion that should fail
|
||||
assert ('mysql_query ("")');
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -244,7 +246,9 @@ assert ('mysql_query ("")');
|
|||
<parameter>varname</parameter>, or &false; on an error.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$ip = getenv ("REMOTE_ADDR"); // get the ip number of the user
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -356,28 +360,32 @@ $ip = getenv ("REMOTE_ADDR"); // get the ip number of the user
|
|||
For example the line below
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
print_r (get_defined_constants());
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
will print a list like:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[E_ERROR] => 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
|
||||
[E_ERROR] => 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
|
||||
)
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -411,8 +419,10 @@ Array
|
|||
For example the lines below
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
print_r (get_extension_funcs ("xml"));
|
||||
print_r (get_extension_funcs ("gd"));
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
will print a list of the functions in the modules
|
||||
|
@ -479,7 +489,8 @@ print_r (get_extension_funcs ("gd"));
|
|||
<example>
|
||||
<title><function>get_included_files</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include("test1.php");
|
||||
include_once("test2.php");
|
||||
|
@ -492,16 +503,19 @@ foreach($included_files as $filename) {
|
|||
echo "$filename\n";
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
will generate the following output:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
test1.php
|
||||
test2.php
|
||||
test3.php
|
||||
test4.php
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -549,27 +563,31 @@ test4.php
|
|||
For example the line below
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
print_r (get_loaded_extensions());
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
will print a list like:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[0] => xml
|
||||
[1] => wddx
|
||||
[2] => standard
|
||||
[3] => session
|
||||
[4] => posix
|
||||
[5] => pgsql
|
||||
[6] => pcre
|
||||
[7] => gd
|
||||
[8] => ftp
|
||||
[9] => db
|
||||
[10] => Calendar
|
||||
[11] => bcmath
|
||||
[0] => xml
|
||||
[1] => wddx
|
||||
[2] => standard
|
||||
[3] => session
|
||||
[4] => posix
|
||||
[5] => pgsql
|
||||
[6] => pcre
|
||||
[7] => gd
|
||||
[8] => ftp
|
||||
[9] => db
|
||||
[10] => Calendar
|
||||
[11] => bcmath
|
||||
)
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -656,8 +674,10 @@ Array
|
|||
<example>
|
||||
<title>getlastmod() example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// outputs e.g. 'Last modified: March 04 1998 20:43:59.'
|
||||
echo "Last modified: ".date ("F d Y H:i:s.", getlastmod());
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -820,11 +840,13 @@ echo "Last modified: ".date ("F d Y H:i:s.", getlastmod());
|
|||
<example>
|
||||
<title>Getrusage Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$dat = getrusage();
|
||||
echo $dat["ru_nswap"]; # number of swaps
|
||||
echo $dat["ru_majflt"]; # number of page faults
|
||||
echo $dat["ru_utime.tv_sec"]; # user time used (seconds)
|
||||
echo $dat["ru_utime.tv_usec"]; # user time used (microseconds)
|
||||
]]>
|
||||
</programlisting>
|
||||
</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:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
...
|
||||
phpcredits(CREDITS_GENERAL);
|
||||
...
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
And if you want to print the core developers and the documentation
|
||||
group, in a page of its own, you will use:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
phpcredits(CREDITS_GROUP + CREDITS_DOCS + CREDITS_FULLPAGE);
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
And if you feel like embedding all the credits in your page, then
|
||||
code like the one below will do it:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<html>
|
||||
<head>
|
||||
<title>My credits page</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>My credits page</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
// some code of your own
|
||||
phpcredits(CREDITS_ALL);
|
||||
// some more code
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1509,8 +1537,10 @@ phpcredits(CREDITS_GROUP + CREDITS_DOCS + CREDITS_FULLPAGE);
|
|||
<example>
|
||||
<title>phpversion() example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// prints e.g. 'Current PHP version: 3.0rel-dev'
|
||||
echo "Current PHP version: ".phpversion();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1577,11 +1607,13 @@ echo "Current PHP version: ".phpversion();
|
|||
<example>
|
||||
<title><function>php_sapi_name</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$sapi_type = php_sapi_name();
|
||||
if ($sapi_type == "cgi")
|
||||
print "You are using CGI PHP\n";
|
||||
else
|
||||
print "You are not using CGI PHP\n";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1611,9 +1643,11 @@ else
|
|||
<example>
|
||||
<title><function>php_uname</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
die("Sorry, this script doesn't run on Windows.\n");
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1665,7 +1699,9 @@ if (substr(php_uname(), 0, 7) == "Windows") {
|
|||
<example>
|
||||
<title>Setting an Environment Variable</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
putenv ("UNIQID=$uniqid");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1790,13 +1826,13 @@ putenv ("UNIQID=$uniqid");
|
|||
If you specify the third optional
|
||||
<parameter>operator</parameter> argument, you
|
||||
can test for a particular relationship. The possible
|
||||
operators are: <literal><</literal>,
|
||||
operators are: <literal><</literal>,
|
||||
<literal>lt</literal>, <literal><=</literal>,
|
||||
<literal>le</literal>, <literal>></literal>,
|
||||
<literal>gt</literal>, <literal>>=</literal>,
|
||||
<literal>ge</literal>, <literal>==</literal>,
|
||||
<literal>=</literal>, <literal>eq</literal>,
|
||||
<literal>!=</literal>, <literal><></literal>,
|
||||
<literal>!=</literal>, <literal><></literal>,
|
||||
<literal>ne</literal> 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");
|
|||
<example>
|
||||
<title><function>version_compare</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// prints -1
|
||||
echo version_compare("4.0.4", "4.0.6");
|
||||
|
||||
// these all print 1
|
||||
echo version_compare("4.0.4", "4.0.6", "<");
|
||||
echo version_compare("4.0.4", "4.0.6", "<");
|
||||
echo version_compare("4.0.6", "4.0.6", "eq");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1860,8 +1898,10 @@ echo version_compare("4.0.6", "4.0.6", "eq");
|
|||
<example>
|
||||
<title><function>zend_version</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// prints e.g. 'Zend engine version: 1.0.4'
|
||||
echo "Zend engine version: ".zend_version();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<reference id="ref.ingres">
|
||||
<title>Ingres II functions</title>
|
||||
<titleabbrev>Ingres II</titleabbrev>
|
||||
|
@ -93,12 +93,14 @@
|
|||
<example>
|
||||
<title><function>ingres_connect</function> example</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = ingres_connect ("mydb", "user", "pass")
|
||||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
ingres_close ($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
|
@ -106,12 +108,14 @@
|
|||
<function>ingres_connect</function> example using default link
|
||||
</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
ingres_connect ("mydb", "user", "pass")
|
||||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
ingres_close ();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para> See also
|
||||
|
@ -296,7 +300,8 @@
|
|||
<example>
|
||||
<title><function>ingres_query</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
ingres_connect ($database, $user, $password);
|
||||
|
||||
ingres_query ("select * from table");
|
||||
|
@ -305,6 +310,7 @@ while ($row = ingres_fetch_row()) {
|
|||
echo $row[2];
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -687,10 +693,12 @@ while ($row = ingres_fetch_row()) {
|
|||
column or make an alias for the column.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
ingres_query(select t1.f1 as foo t2.f1 as bar from t1, t2);
|
||||
$result = ingres_fetch_array();
|
||||
$foo = $result["foo"];
|
||||
$bar = $result["bar"];
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -709,7 +717,8 @@ $bar = $result["bar"];
|
|||
<example>
|
||||
<title><function>ingres_fetch_array</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
ingres_connect ($database, $user, $password);
|
||||
|
||||
ingres_query ("select * from table");
|
||||
|
@ -720,6 +729,7 @@ while ($row = ingres_fetch_array()) {
|
|||
echo $row[2];
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -767,7 +777,8 @@ while ($row = ingres_fetch_array()) {
|
|||
<example>
|
||||
<title><function>ingres_fetch_row</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
ingres_connect ($database, $user, $password);
|
||||
|
||||
ingres_query ("select * from table");
|
||||
|
@ -776,6 +787,7 @@ while ($row = ingres_fetch_row()) {
|
|||
echo $row[2];
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -837,7 +849,8 @@ while ($row = ingres_fetch_row()) {
|
|||
<example>
|
||||
<title><function>ingres_fetch_object</function> example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
ingres_connect ($database, $user, $password);
|
||||
ingres_query ("select * from table");
|
||||
while ($row = ingres_fetch_object()) {
|
||||
|
@ -845,6 +858,7 @@ while ($row = ingres_fetch_object()) {
|
|||
echo $row->fullname;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<!-- $Revision: 1.15 $ -->
|
||||
<reference id="ref.ircg">
|
||||
<title>IRC Gateway Functions</title>
|
||||
<titleabbrev>IRC Gateway</titleabbrev>
|
||||
|
@ -108,11 +108,13 @@
|
|||
<example>
|
||||
<title><function>ircg_fetch_error_msg</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if (!ircg_join ($id, "#php")) {
|
||||
$error = ircg_fetch_error_msg($id);
|
||||
print ("Can't join channel #php. Errorcode:
|
||||
$error[0] Description: $error[1]");
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<reference id="ref.java">
|
||||
<title>Java</title>
|
||||
<titleabbrev>PHP / Java Integration</titleabbrev>
|
||||
|
@ -20,44 +20,48 @@
|
|||
<example>
|
||||
<title>Java Example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// get instance of Java class java.lang.System in PHP
|
||||
$system = new Java('java.lang.System');
|
||||
|
||||
// demonstrate property access
|
||||
print 'Java version='.$system->getProperty('java.version').' <br>';
|
||||
print 'Java vendor=' .$system->getProperty('java.vendor').' <br>';
|
||||
print 'OS='.$system->getProperty('os.name').' '.
|
||||
$system->getProperty('os.version').' on '.
|
||||
$system->getProperty('os.arch').' <br>';
|
||||
print 'Java version='.$system->getProperty('java.version').' <br>';
|
||||
print 'Java vendor=' .$system->getProperty('java.vendor').' <br>';
|
||||
print 'OS='.$system->getProperty('os.name').' '.
|
||||
$system->getProperty('os.version').' on '.
|
||||
$system->getProperty('os.arch').' <br>';
|
||||
|
||||
// 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'));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>AWT Example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// This example is only intented to be run as a CGI.
|
||||
|
||||
$frame = new Java('java.awt.Frame', 'PHP');
|
||||
$button = new Java('java.awt.Button', 'Hello Java World!');
|
||||
|
||||
$frame->add('North', $button);
|
||||
$frame->validate();
|
||||
$frame->pack();
|
||||
$frame->visible = True;
|
||||
$frame->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();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
|
@ -200,9 +204,10 @@
|
|||
<example>
|
||||
<title>Java exception handler</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stack = new Java('java.util.Stack');
|
||||
$stack->push(1);
|
||||
$stack->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();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.35 $ -->
|
||||
<!-- $Revision: 1.36 $ -->
|
||||
<reference id="ref.ldap">
|
||||
<title>LDAP functions</title>
|
||||
<titleabbrev>LDAP</titleabbrev>
|
||||
|
@ -72,48 +72,50 @@
|
|||
|
||||
<example>
|
||||
<title>LDAP search example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// basic sequence with LDAP is connect, bind, search, interpret search
|
||||
// result, close connection
|
||||
|
||||
echo "<h3>LDAP query test</h3>";
|
||||
echo "<h3>LDAP query test</h3>";
|
||||
echo "Connecting ...";
|
||||
$ds=ldap_connect("localhost"); // must be a valid LDAP server!
|
||||
echo "connect result is ".$ds."<p>";
|
||||
echo "connect result is ".$ds."<p>";
|
||||
|
||||
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."<p>";
|
||||
|
||||
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."<p>";
|
||||
|
||||
echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
|
||||
echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
|
||||
|
||||
echo "Getting entries ...<p>";
|
||||
echo "Getting entries ...<p>";
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
echo "Data for ".$info["count"]." items returned:<p>";
|
||||
echo "Data for ".$info["count"]." items returned:<p>";
|
||||
|
||||
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"] ."<br>";
|
||||
echo "first cn entry is: ". $info[$i]["cn"][0] ."<br>";
|
||||
echo "first email entry is: ". $info[$i]["mail"][0] ."<p>";
|
||||
}
|
||||
|
||||
echo "Closing connection";
|
||||
ldap_close($ds);
|
||||
|
||||
} else {
|
||||
echo "<h4>Unable to connect to LDAP server</h4>";
|
||||
echo "<h4>Unable to connect to LDAP server</h4>";
|
||||
}
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<sect2 id="ldap.using">
|
||||
<title>Using the PHP LDAP calls</title>
|
||||
|
@ -237,7 +239,8 @@ if ($ds) {
|
|||
<example>
|
||||
<title>Complete example with authenticated bind</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
$ds=ldap_connect("localhost"); // assuming the LDAP server is on this host
|
||||
|
||||
if ($ds) {
|
||||
|
@ -258,6 +261,7 @@ if ($ds) {
|
|||
echo "Unable to connect to LDAP server";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -349,7 +353,8 @@ if ($ds) {
|
|||
<example>
|
||||
<title>Complete example of password check</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$ds=ldap_connect("localhost"); // assuming the LDAP server is on this host
|
||||
|
||||
|
@ -383,8 +388,9 @@ if ($ds) {
|
|||
} else {
|
||||
echo "Unable to connect to LDAP server.";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
|
@ -534,11 +540,13 @@ if ($ds) {
|
|||
<example>
|
||||
<title>Enumerating all LDAP error messages</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
for($i=0; $i<100; $i++) {
|
||||
printf("Error $i: %s<br>\n", ldap_err2str($i));
|
||||
<![CDATA[
|
||||
<?php
|
||||
for($i=0; $i<100; $i++) {
|
||||
printf("Error $i: %s<br>\n", ldap_err2str($i));
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
</refsect1>
|
||||
|
@ -576,7 +584,8 @@ if ($ds) {
|
|||
<example>
|
||||
<title>Generating and catching an error</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
// This example contains an error, which we will catch.
|
||||
$ld = ldap_connect("localhost");
|
||||
$bind = ldap_bind($ld);
|
||||
|
@ -584,13 +593,14 @@ $bind = ldap_bind($ld);
|
|||
// must be "objectclass=*" to work.
|
||||
$res = @ldap_search($ld, "o=Myorg, c=DE", "objectclass");
|
||||
if (!$res) {
|
||||
printf("LDAP-Errno: %s<br>\n", ldap_errno($ld));
|
||||
printf("LDAP-Error: %s<br>\n", ldap_error($ld));
|
||||
die("Argh!<br>\n");
|
||||
printf("LDAP-Errno: %s<br>\n", ldap_errno($ld));
|
||||
printf("LDAP-Error: %s<br>\n", ldap_error($ld));
|
||||
die("Argh!<br>\n");
|
||||
}
|
||||
$info = ldap_get_entries($ld, $res);
|
||||
printf("%d matching entries.<br>\n", $info["count"]);
|
||||
printf("%d matching entries.<br>\n", $info["count"]);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
<para>
|
||||
|
@ -812,6 +822,7 @@ return_value["attribute"][i] = ith value of the attribute
|
|||
<title>Show the list of attributes held for a particular directory
|
||||
entry </title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is the link identifier for the directory
|
||||
|
||||
// $sr is a valid search result from a prior call to
|
||||
|
@ -821,10 +832,11 @@ $entry = ldap_first_entry($ds, $sr);
|
|||
|
||||
$attrs = ldap_get_attributes($ds, $entry);
|
||||
|
||||
echo $attrs["count"]." attributes held for this entry:<p>";
|
||||
echo $attrs["count"]." attributes held for this entry:<p>";
|
||||
|
||||
for ($i=0; $i<$attrs["count"]; $i++)
|
||||
echo $attrs[$i]."<br>";
|
||||
for ($i=0; $i<$attrs["count"]; $i++)
|
||||
echo $attrs[$i]."<br>";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
|
||||
|
@ -944,11 +956,13 @@ return_value[i]["attribute"][j] = jth value of attribute in ith entry
|
|||
<example>
|
||||
<title>Check protocol version</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
if (ldap_get_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version))
|
||||
echo "Using protocol version $version";
|
||||
else
|
||||
echo "Unable to determine protocol version";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1011,6 +1025,7 @@ return_value[i] = ith value of attribute
|
|||
<title>List all values of the "mail" attribute for a
|
||||
directory entry </title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
|
||||
// $sr is a valid search result from a prior call to
|
||||
|
@ -1021,10 +1036,11 @@ return_value[i] = ith value of attribute
|
|||
|
||||
$values = ldap_get_values($ds, $entry,"mail");
|
||||
|
||||
echo $values["count"]." email addresses for this entry.<p>";
|
||||
echo $values["count"]." email addresses for this entry.<p>";
|
||||
|
||||
for ($i=0; $i < $values["count"]; $i++)
|
||||
echo $values[$i]."<br>";
|
||||
for ($i=0; $i < $values["count"]; $i++)
|
||||
echo $values[$i]."<br>";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
|
||||
|
@ -1127,6 +1143,7 @@ for ($i=0; $i < $values["count"]; $i++)
|
|||
<title>Produce a list of all organizational units of an organization
|
||||
</title>
|
||||
<programlisting role="php3">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
|
||||
$basedn = "o=My Company, c=US";
|
||||
|
@ -1136,8 +1153,9 @@ $sr=ldap_list($ds, $basedn, "ou=*", $justthese);
|
|||
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
|
||||
for ($i=0; $i<$info["count"]; $i++)
|
||||
for ($i=0; $i<$info["count"]; $i++)
|
||||
echo $info[$i]["ou"][0] ;
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
<para>
|
||||
|
@ -1539,6 +1557,7 @@ for ($i=0; $i<$info["count"]; $i++)
|
|||
<example>
|
||||
<title>LDAP search</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
|
||||
// $person is all or part of a person's name, eg "Jo"
|
||||
|
@ -1551,7 +1570,8 @@ $sr=ldap_search($ds, $dn, $filter, $justthese);
|
|||
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
|
||||
print $info["count"]." entries returned<p>";
|
||||
print $info["count"]." entries returned<p>";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
<para>
|
||||
|
@ -1626,16 +1646,19 @@ print $info["count"]." entries returned<p>";
|
|||
<example>
|
||||
<title>Set protocol version</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
|
||||
echo "Using LDAPv3";
|
||||
else
|
||||
echo "Failed to set protocol version to 3";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Set server controls</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// $ds is a valid link identifier for a directory server
|
||||
// control with no value
|
||||
$ctrl1 = array("oid" => "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";
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.32 $ -->
|
||||
<!-- $Revision: 1.33 $ -->
|
||||
<reference id="ref.mail">
|
||||
<title>Mail functions</title>
|
||||
<titleabbrev>Mail</titleabbrev>
|
||||
|
@ -102,7 +102,9 @@
|
|||
<example>
|
||||
<title>Sending mail.</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example></para>
|
||||
<simpara>
|
||||
|
@ -124,10 +126,12 @@ mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");
|
|||
<example>
|
||||
<title>Sending mail with extra headers.</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
mail("nobody@example.com", "the subject", $message,
|
||||
"From: webmaster@$SERVER_NAME\r\n"
|
||||
."Reply-To: webmaster@$SERVER_NAME\r\n"
|
||||
."X-Mailer: PHP/" . phpversion());
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -143,8 +147,10 @@ mail("nobody@example.com", "the subject", $message,
|
|||
<example>
|
||||
<title>Sending mail with extra headers and setting an additional command line parameter.</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
mail("nobody@example.com", "the subject", $message,
|
||||
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -159,32 +165,33 @@ mail("nobody@example.com", "the subject", $message,
|
|||
<example>
|
||||
<title>Sending complex email.</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
/* recipients */
|
||||
$to = "Mary <mary@example.com>" . ", " ; //note the comma
|
||||
$to .= "Kelly <kelly@example.com>";
|
||||
$to = "Mary <mary@example.com>" . ", " ; //note the comma
|
||||
$to .= "Kelly <kelly@example.com>";
|
||||
|
||||
/* 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>
|
||||
<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>
|
||||
';
|
||||
|
||||
/* 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 <birthday@example.com>\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);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -233,10 +241,12 @@ mail($to, $subject, $message, $headers);
|
|||
<example>
|
||||
<title>Calculating the hash and subscribing a user</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$user = "joecool@example.com";
|
||||
$hash = ezmlm_hash ($user);
|
||||
$query = sprintf ("INSERT INTO sample VALUES (%s, '%s')", $hash, $user);
|
||||
$db->query($query); // using PHPLIB db interface
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.58 $ -->
|
||||
<!-- $Revision: 1.59 $ -->
|
||||
<reference id="ref.math">
|
||||
<title>Mathematical Functions</title>
|
||||
<titleabbrev>Math</titleabbrev>
|
||||
|
@ -354,7 +354,9 @@
|
|||
<example>
|
||||
<title><function>base_convert</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$binary = base_convert ($hexadecimal, 16, 2);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -661,6 +663,7 @@ $binary = base_convert ($hexadecimal, 16, 2);
|
|||
<example>
|
||||
<title><function>hexdec</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
var_dump(hexdec("See"));
|
||||
var_dump(hexdec("ee"));
|
||||
// both prints "int(238)"
|
||||
|
@ -668,6 +671,7 @@ var_dump(hexdec("ee"));
|
|||
var_dump(hexdec("that"));
|
||||
var_dump(hexdec("a0"));
|
||||
// both prints int(160)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -899,6 +903,7 @@ var_dump(hexdec("a0"));
|
|||
<parameter>seed</parameter>.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// seed with microseconds
|
||||
function make_seed() {
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
|
@ -906,6 +911,7 @@ function make_seed() {
|
|||
}
|
||||
mt_srand(make_seed());
|
||||
$randval = mt_rand();
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1000,7 +1006,8 @@ $randval = mt_rand();
|
|||
thousand separator. This is achieved with this line :
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$number = 1234.56;
|
||||
|
||||
|
@ -1019,7 +1026,8 @@ $randval = mt_rand();
|
|||
$english_format_number = number_format($number, 2, '.', '');
|
||||
// 1234.56
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1077,10 +1085,10 @@ $randval = mt_rand();
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
|
||||
<![CDATA[
|
||||
echo pi();
|
||||
// will echo 3.1415926535898
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1249,6 +1257,7 @@ echo pow(-1, 5.5); // error
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$foo = round(3.4); // $foo == 3.0
|
||||
$foo = round(3.5); // $foo == 4.0
|
||||
$foo = round(3.6); // $foo == 4.0
|
||||
|
@ -1257,6 +1266,7 @@ $foo = round(3.6, 0); // equivalent with above
|
|||
$foo = round(1.95583, 2); // $foo == 1.96
|
||||
|
||||
$foo = round(1241757, -3); // $foo == 1242000
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1356,6 +1366,7 @@ $foo = round(1241757, -3); // $foo == 1242000
|
|||
<parameter>seed</parameter>.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// seed with microseconds
|
||||
function make_seed() {
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
|
@ -1363,6 +1374,7 @@ function make_seed() {
|
|||
}
|
||||
srand(make_seed());
|
||||
$randval = rand();
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.15 $ -->
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<reference id="ref.mbstring">
|
||||
<title>Multi-Byte String Functions</title>
|
||||
<titleabbrev>
|
||||
|
@ -67,13 +67,14 @@
|
|||
PHP and does NOT work with PHP.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
|
||||
<![CDATA[
|
||||
Character encodings work with PHP:
|
||||
ISO-8859-*, EUC-JP, UTF-8
|
||||
|
||||
|
||||
Character encodings do NOT work with PHP:
|
||||
JIS, SJIS
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -166,9 +167,10 @@ JIS, SJIS
|
|||
Disable HTTP input conversion in php.ini
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<![CDATA[
|
||||
;; Disable HTTP Input conversion
|
||||
mbstring.http_input = pass
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -206,7 +208,7 @@ mbstring.http_input = pass
|
|||
<example>
|
||||
<title><literal>php.ini</literal> setting example</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<![CDATA[
|
||||
;; Enable output character encoding conversion for all PHP pages
|
||||
|
||||
;; Enable Output Buffering
|
||||
|
@ -214,6 +216,7 @@ output_buffering = On
|
|||
|
||||
;; Set mb_output_handler to enable output conversion
|
||||
output_handler = mb_output_handler
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -221,8 +224,8 @@ output_handler = mb_output_handler
|
|||
<example>
|
||||
<title>Script example</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// Enable output character encoding conversion only for this page
|
||||
|
||||
|
@ -233,7 +236,8 @@ mb_http_output('SJIS');
|
|||
// callback function
|
||||
ob_start('mb_output_handler');
|
||||
|
||||
?>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -360,7 +364,7 @@ ob_start('mb_output_handler');
|
|||
<example>
|
||||
<title><literal>php.ini</literal> setting example</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<![CDATA[
|
||||
;; Set default internal encoding
|
||||
;; Note: Make sure to use character encoding works with PHP
|
||||
mbstring.internal_encoding = UTF-8 ; Set internal encoding to UTF-8
|
||||
|
@ -385,6 +389,7 @@ mbstring.detect_order = ASCII,JIS,UTF-8,SJIS,EUC-JP ; Specify order
|
|||
mbstring.substitute_character = 12307 ; Specify Unicode value
|
||||
mbstring.substitute_character = none ; Do not print character
|
||||
mbstring.substitute_character = long ; Long Example: U+3000,JIS+7E7E
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -392,7 +397,7 @@ mbstring.substitute_character = long ; Long Example: U+3000,JIS+7E7E
|
|||
<example>
|
||||
<title><literal>php.ini</literal> setting for <literal>EUC-JP</literal> users</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<![CDATA[
|
||||
;; Disable Output Buffering
|
||||
output_buffering = Off
|
||||
|
||||
|
@ -410,6 +415,7 @@ mbstring.internal_encoding = EUC-JP
|
|||
|
||||
;; Do not print invalid characters
|
||||
mbstring.substitute_character = none
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -417,7 +423,7 @@ mbstring.substitute_character = none
|
|||
<example>
|
||||
<title><literal>php.ini</literal> setting for <literal>SJIS</literal> users</title>
|
||||
<programlisting role="php">
|
||||
|
||||
<![CDATA[
|
||||
;; Enable Output Buffering
|
||||
output_buffering = On
|
||||
|
||||
|
@ -438,6 +444,7 @@ mbstring.internal_encoding = EUC-JP
|
|||
|
||||
;; Do not print invalid characters
|
||||
mbstring.substitute_character = none
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -662,11 +669,13 @@ mbstring.substitute_character = none
|
|||
<example>
|
||||
<title><function>mb_internal_encoding</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Set internal character encoding to UTF-8 */
|
||||
mb_internal_encoding("UTF-8");
|
||||
|
||||
/* Display current internal character encoding */
|
||||
echo mb_internal_encoding();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -818,12 +827,14 @@ echo mb_internal_encoding();
|
|||
<example>
|
||||
<title>Useless detect order example</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
; Always detect as ISO-8859-1
|
||||
detect_order = ISO-8859-1, UTF-8
|
||||
|
||||
; Always detect as UTF-8, since ASCII/UTF-7 values are
|
||||
; valid for UTF-8
|
||||
detect_order = UTF-8, ASCII, UTF-7
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -832,6 +843,7 @@ detect_order = UTF-8, ASCII, UTF-7
|
|||
<example>
|
||||
<title><function>mb_detect_order</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Set detection order by enumerated list */
|
||||
mb_detect_order("eucjp-win,sjis-win,UTF-8");
|
||||
|
||||
|
@ -843,6 +855,7 @@ mb_detect_order($ary);
|
|||
|
||||
/* Display current detection order */
|
||||
echo implode(", ", mb_detect_order());
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -910,6 +923,7 @@ echo implode(", ", mb_detect_order());
|
|||
<example>
|
||||
<title><function>mb_substitute_character</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Set with Unicode U+3013 (GETA MARK) */
|
||||
mb_substitute_character(0x3013);
|
||||
|
||||
|
@ -918,6 +932,7 @@ mb_substitute_character("long");
|
|||
|
||||
/* Display current setting */
|
||||
echo mb_substitute_character();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -981,8 +996,10 @@ echo mb_substitute_character();
|
|||
<example>
|
||||
<title><function>mb_output_handler</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
mb_http_output("UTF-8");
|
||||
ob_start("mb_output_handler");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1023,10 +1040,12 @@ ob_start("mb_output_handler");
|
|||
<example>
|
||||
<title><function>mb_preferred_mime_string</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$outputenc = "sjis-win";
|
||||
mb_http_output($outputenc);
|
||||
ob_start("mb_output_handler");
|
||||
header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc));
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1309,6 +1328,7 @@ header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc))
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Character width
|
||||
|
||||
U+0000 - U+0019 0
|
||||
|
@ -1316,6 +1336,7 @@ header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc))
|
|||
U+2000 - U+FF60 2
|
||||
U+FF61 - U+FF9F 1
|
||||
U+FFA0 - 2
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1375,7 +1396,9 @@ header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc))
|
|||
<example>
|
||||
<title><function>mb_strimwidth</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$str = mb_strimwidth($str, 0, 40, "..>");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1422,6 +1445,7 @@ $str = mb_strimwidth($str, 0, 40, "..>");
|
|||
<example>
|
||||
<title><function>mb_convert_encoding</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Convert internal character encoding to SJIS */
|
||||
$str = mb_convert_encoding($str, "SJIS");
|
||||
|
||||
|
@ -1433,7 +1457,7 @@ $str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
|
|||
|
||||
/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
|
||||
$str = mb_convert_encoding($str, "EUC-JP", "auto");
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1478,6 +1502,7 @@ $str = mb_convert_encoding($str, "EUC-JP", "auto");
|
|||
<example>
|
||||
<title><function>mb_detect_encoding</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Detect character encoding with current detect_order */
|
||||
echo mb_detect_encoding($str);
|
||||
|
||||
|
@ -1492,6 +1517,7 @@ $ary[] = "ASCII";
|
|||
$ary[] = "JIS";
|
||||
$ary[] = "EUC-JP";
|
||||
echo mb_detect_encoding($str, $ary);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1538,6 +1564,7 @@ echo mb_detect_encoding($str, $ary);
|
|||
<para>
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Applicable Conversion Options
|
||||
|
||||
option : Specify with conversion of following options. Default "KV"
|
||||
|
@ -1558,6 +1585,7 @@ echo mb_detect_encoding($str, $ary);
|
|||
"c" : Convert "zen-kaku kata-kana" to "zen-kaku hira-gana"
|
||||
"C" : Convert "zen-kaku hira-gana" to "zen-kaku kata-kana"
|
||||
"V" : Collapse voiced sound notation and convert them into a character. Use with "K","H"
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -1565,12 +1593,14 @@ echo mb_detect_encoding($str, $ary);
|
|||
<example>
|
||||
<title><function>mb_convert_kana</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Convert all "kana" to "zen-kaku" "kata-kana" */
|
||||
$str = mb_convert_kana($str, "KVC");
|
||||
|
||||
/* Convert "han-kaku" "kata-kana" to "zen-kaku" "kata-kana"
|
||||
and "zen-kaku" alpha-numeric to "han-kaku" */
|
||||
$str = mb_convert_kana($str, "KVa");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1623,11 +1653,13 @@ $str = mb_convert_kana($str, "KVa");
|
|||
<example>
|
||||
<title><function>mb_convert_kana</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$name = ""; // kanji
|
||||
$mbox = "kru";
|
||||
$doma = "gtinn.mon";
|
||||
$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">";
|
||||
$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">";
|
||||
echo $addr;
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1710,9 +1742,11 @@ echo $addr;
|
|||
<example>
|
||||
<title><function>mb_convert_variables</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Convert variables $post1, $post2 to internal encoding */
|
||||
$interenc = mb_internal_encoding();
|
||||
$inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1756,6 +1790,7 @@ $inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $pos
|
|||
<example>
|
||||
<title><parameter>convmap</parameter> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$convmap = array (
|
||||
int start_code1, int end_code1, int offset1, int mask1,
|
||||
int start_code2, int end_code2, int offset2, int mask2,
|
||||
|
@ -1764,6 +1799,7 @@ $convmap = array (
|
|||
// Specify Unicode value for start_codeN and end_codeN
|
||||
// Add offsetN to value and take bit-wise 'AND' with maskN, then
|
||||
// it converts value to numeric string reference.
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1773,6 +1809,7 @@ $convmap = array (
|
|||
<function>mb_encode_numericentity</function> example
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
/* Convert Left side of ISO-8859-1 to HTML numeric character reference */
|
||||
$convmap = array(0x80, 0xff, 0, 0xff);
|
||||
$str = mb_encode_numericentity($str, $convmap, "ISO-8859-1");
|
||||
|
@ -1791,6 +1828,7 @@ $convmap = array(
|
|||
0xe2f0, 0xe32e, 0x1150, 0xffff,
|
||||
0xe32f, 0xe3ab, 0x1151, 0xffff );
|
||||
$str = mb_encode_numericentity($str, $convmap, "sjis-win");
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1837,6 +1875,7 @@ $str = mb_encode_numericentity($str, $convmap, "sjis-win");
|
|||
<example>
|
||||
<title><parameter>convmap</parameter> example</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
$convmap = array (
|
||||
int start_code1, int end_code1, int offset1, int mask1,
|
||||
int start_code2, int end_code2, int offset2, int mask2,
|
||||
|
@ -1845,6 +1884,7 @@ $convmap = array (
|
|||
// Specify Unicode value for start_codeN and end_codeN
|
||||
// Add offsetN to value and take bit-wise 'AND' with maskN,
|
||||
// then convert value to numeric string reference.
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue