Date: 09/17/00
- Next message: Andrei Zmievski: "Re: [PHP-DOC] cvs: phpdoc /en/appendices debugger.xml phpdevel.xml /en/chapters intro.xml /en/features file-upload.xml /en/functions array.xml com.xml cpdf.xml cybercash.xml domxml.xml errorfunc.xml funchand.xml http.xml ibase.xml image.xml imap.xml info.xml math.xml misc.xml pdf.xml posix.xml recode.xml swf.xml /en/language control-structures.xml functions.xml operators.xml types.xml variables.xml"
- Previous message: Martin Samesch: "[PHP-DOC] cvs: phpdoc /de/functions cpdf.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
rasmus Sun Sep 17 15:50:00 2000 EDT
Added files:
/phpdoc/hu/functions errorfunc.xml funchand.xml satellite.xml
Modified files:
/phpdoc/hu chapters.ent
Log:
Add missing files - functions still need to be shuffled around
Index: phpdoc/hu/chapters.ent
diff -u phpdoc/hu/chapters.ent:1.5 phpdoc/hu/chapters.ent:1.6
--- phpdoc/hu/chapters.ent:1.5 Sat Sep 2 06:59:30 2000
+++ phpdoc/hu/chapters.ent Sun Sep 17 15:49:59 2000
@@ -45,11 +45,13 @@
<!ENTITY reference.dir SYSTEM "functions/dir.xml">
<!ENTITY reference.dl SYSTEM "functions/dl.xml">
<!ENTITY reference.domxml SYSTEM "functions/domxml.xml">
+<!ENTITY reference.errorfunc SYSTEM "functions/errorfunc.xml">
<!ENTITY reference.exec SYSTEM "functions/exec.xml">
<!ENTITY reference.fdf SYSTEM "functions/fdf.xml">
<!ENTITY reference.filepro SYSTEM "functions/filepro.xml">
<!ENTITY reference.filesystem SYSTEM "functions/filesystem.xml">
<!ENTITY reference.ftp SYSTEM "functions/ftp.xml">
+<!ENTITY reference.funchand SYSTEM "functions/funchand.xml">
<!ENTITY reference.gettext SYSTEM "functions/gettext.xml">
<!ENTITY reference.http SYSTEM "functions/http.xml">
<!ENTITY reference.hw SYSTEM "functions/hw.xml">
@@ -83,6 +85,7 @@
<!ENTITY reference.readline SYSTEM "functions/readline.xml">
<!ENTITY reference.recode SYSTEM "functions/recode.xml">
<!ENTITY reference.regex SYSTEM "functions/regex.xml">
+<!ENTITY reference.satellite SYSTEM "functions/satellite.xml">
<!ENTITY reference.sem SYSTEM "functions/sem.xml">
<!ENTITY reference.session SYSTEM "functions/session.xml">
<!ENTITY reference.snmp SYSTEM "functions/snmp.xml">
Index: phpdoc/hu/functions/errorfunc.xml
+++ phpdoc/hu/functions/errorfunc.xml
<reference id="ref.errorfunc">
<title>Error Handling and Logging Functions</title>
<titleabbrev>Errors and Logging</titleabbrev>
<partintro>
<para>
These are functions dealing with error handling and logging. They
allow you to define your own error handling rules, as well as modify
the way the errors can be logged. This allows you to change and
enhance error reporting to suit your needs.
</para>
<para>
With the logging functions, you can send messages directly to other
machines, to an email (or email to pager gateway!), to system logs,
etc., so you can selectively log and monitor the most important parts
of your applications and websites.
</para>
<para>
The error reporting functions allow you to customize what level and
kind of error feedback is given, ranging from simple notices to customized
functions returned during errors.
</para>
</partintro>
<refentry id="function.error-log">
<refnamediv>
<refname>error_log</refname>
<refpurpose>send an error message somewhere</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>error_log</function></funcdef>
<paramdef>string <parameter>message</parameter></paramdef>
<paramdef>int <parameter>message_type</parameter></paramdef>
<paramdef>string
<parameter><optional>destination</optional></parameter>
</paramdef>
<paramdef>string
<parameter><optional>extra_headers</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Sends an error message to the web server's error log, a
<acronym>TCP</acronym> port or to a file. The first parameter,
<parameter>message</parameter>, is the error message that should
be logged. The second parameter,
<parameter>message_type</parameter> says where the message should
go:
<table>
<title><function>error_log</function> log types</title>
<tgroup cols="2">
<tbody>
<row>
<entry>0</entry>
<entry>
<parameter>message</parameter> is sent to PHP's system
logger, using the Operating System's system logging
mechanism or a file, depending on what the <link
linkend="ini.error-log">error_log</link> configuration
directive is set to.
</entry>
</row>
<row>
<entry>1</entry>
<entry>
<parameter>message</parameter> is sent by email to the
address in the <parameter>destination</parameter> parameter.
This is the only message type where the fourth parameter,
<parameter>extra_headers</parameter> is used. This message
type uses the same internal function as
<function>Mail</function> does.
</entry>
</row>
<row>
<entry>2</entry>
<entry>
<parameter>message</parameter> is sent through the PHP debugging
connection. This option is only available if <link
linkend="install.configure.enable-debugger">remote debugging has
been enabled</link>. In this case, the
<parameter>destination</parameter> parameter specifies the host
name or IP address and optionally, port number, of the socket
receiving the debug information.
</entry>
</row>
<row>
<entry>3</entry>
<entry>
<parameter>message</parameter> is appended to the file
<parameter>destination</parameter>.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<example role="php">
<title><function>error_log</function> examples</title>
<programlisting role="php">
// Send notification through the server log if we can not
// connect to the database.
if (!Ora_Logon ($username, $password)) {
error_log ("Oracle database not available!", 0);
}
// Notify administrator by email if we run out of FOO
if (!($foo = allocate_new_foo()) {
error_log ("Big trouble, we're all out of FOOs!", 1,
"operator <email protected>");
}
// other ways of calling error_log():
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>
</refsect1>
</refentry>
<refentry id="function.error-reporting">
<refnamediv>
<refname>error_reporting</refname>
<refpurpose>set which PHP errors are reported</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>error_reporting</function></funcdef>
<paramdef>int
<parameter><optional>level</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Sets PHP's error reporting level and returns the old level. The
error reporting level is either a bitmask, or named constant. Using
named constants is strongly encouraged to ensure compatibility for
future versions. As error levels are added, the range of integers
increases, so older integer-based error levels will not always
behave as expected.
<example role="php">
<title>Error Integer changes</title>
<programlisting role="php">
error_reporting (55); // PHP 3 equivalent to E_ALL ^ E_NOTICE
/* ...in PHP 4, '55' would mean (E_ERROR | E_WARNING | E_PARSE |
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:
<table>
<title><function>error_reporting</function> bit values</title>
<tgroup cols="2">
<thead>
<row>
<entry>constant</entry>
<entry>value</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>
<link linkend="internal.e-error">E_ERROR</link>
</entry>
</row>
<row>
<entry>2</entry>
<entry>
<link linkend="internal.e-warning">E_WARNING</link>
</entry>
</row>
<row>
<entry>4</entry>
<entry>
<link linkend="internal.e-parse">E_PARSE</link>
</entry>
</row>
<row>
<entry>8</entry>
<entry>
<link linkend="internal.e-notice">E_NOTICE</link>
</entry>
</row>
<row>
<entry>16</entry>
<entry>
<link linkend="internal.e-core-error">E_CORE_ERROR</link>
</entry>
</row>
<row>
<entry>32</entry>
<entry>
<link linkend="internal.e-core-warning">E_CORE_WARNING</link>
</entry>
</row>
<row>
<entry>64</entry>
<entry>
<link linkend="internal.e-compile-error">E_COMPILE_ERROR</link>
</entry>
</row>
<row>
<entry>128</entry>
<entry>
<link linkend="internal.e-compile-warning">E_COMPILE_WARNING</link>
</entry>
</row>
<row>
<entry>256</entry>
<entry>
<link linkend="internal.e-user-error">E_USER_ERROR</link>
</entry>
</row>
<row>
<entry>512</entry>
<entry>
<link linkend="internal.e-user-warning">E_USER_WARNING</link>
</entry>
</row>
<row>
<entry>1024</entry>
<entry>
<link linkend="internal.e-user-error">E_USER_NOTICE</link>
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<example role="php">
<title><function>error_reporting</function> examples</title>
<programlisting role="php">
error_reporting(0);
/* Turn off all reporting */
error_reporting (7); // Old syntax, PHP 2/3
error_reporting (E_ERROR | E_WARNING | E_PARSE); // New syntax for PHP 3/4
/* Good to use for simple running errors */
error_reporting (15); // Old syntax, PHP 2/3
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // New syntax for PHP 3/4
/* good for code authoring to report uninitialized or (possibly mis-spelled) variables */
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>
</refsect1>
</refentry>
<refentry id="function.restore-error-handler">
<refnamediv>
<refname>restore_error_handler</refname>
<refpurpose>
Restores the previous error handler function
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>restore_error_handler</function></funcdef>
<paramdef>void</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Used after changing the error handler function using
<function>set_error_handler</function>, to revert to the previous error
handler (which could be the built-in or a user defined function)
</para>
<para>
See also <function>error_reporting</function>,
<function>set_error_handler</function>,
<function>trigger_error</function>, <function>user_error</function>
</para>
</refsect1>
</refentry>
<refentry id="function.set-error-handler">
<refnamediv>
<refname>set_error_handler</refname>
<refpurpose>
Sets a user-defined error handler function.
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>string <function>set_error_handler</function></funcdef>
<paramdef>string <parameter>error_handler</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Sets a user function (<parameter>error_handler</parameter>) to handle
errors in a script. Returns the previously defined error handler (if
any), or false on error. This function can be used for defining your own
way of handling errors during runtime, for example in applications in
which you need to do cleanup of data/files when a critical error happens,
or when you need to trigger an error under certain conditions (using
<function>trigger_error</function>)
</para>
<para>
The user function needs to accept 2 parameters: the error code, and a
string describing the error. The example below shows the handling of
internal execptions by triggering errors and handling them with a user
defined function:
<example>
<title>
Error handling with <function>set_error_handler</function> and
<function>trigger_error</function>
</title>
<programlisting role="php">
<?php
// redefine the user error constants - PHP 4 only
define (FATAL,E_USER_ERROR);
define (ERROR,E_USER_WARNING);
define (WARNING,E_USER_NOTICE);
// set the error reporting level for this script
error_reporting (FATAL + ERROR + WARNING);
// error handler function
function myErrorHandler ($errno, $errstr) {
switch ($errno) {
case FATAL:
echo "<b>FATAL</b> [$errno] $errstr<br>\n";
echo " Fatal error in line ".__LINE__." of file ".__FILE__;
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";
break;
case WARNING:
echo "<b>WARNING</b> [$errno] $errstr<br>\n";
break;
default:
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",
FATAL);
if (!is_array($vect)) {
trigger_error("Incorrect input vector, array of values expected", ERROR);
return null;
}
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)",
WARNING);
$temp[$i] = log($scale) * $vect[$i];
}
return $temp;
}
// set to the user defined error handler
$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);
print_r($a);
// now generate second array, generating a warning
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);
var_dump($c);
// this is a critical error, log of zero or negative number is undefined
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>
vector a
Array
(
[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>
Array
(
[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>
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 16 of file trigger_error.php, PHP 4.0.1pl2 (Linux)<br>
Aborting...<br>
</programlisting>
</informalexample>
</para>
<para>
See also <function>error_reporting</function>,
<function>restore_error_handler</function>,
<function>trigger_error</function>, <function>user_error</function>
</para>
</refsect1>
</refentry>
<refentry id="function.trigger-error">
<refnamediv>
<refname>trigger_error</refname>
<refpurpose>
Generates a user-level error/warning/notice message
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>trigger_error</function></funcdef>
<paramdef>string <parameter>error_msg</parameter></paramdef>
<paramdef>int
<parameter><optional>error_type</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Used to trigger a user error condition, it can be used by in conjunction
with the built-in error handler, or with a user defined function that has
been set as the new error handler
(<function>set_error_handler</function>). This function is useful when
you need to generate a particular response to an exception at runtime.
For example:
<informalexample>
<programlisting>
if (assert ($divisor == 0))
trigger_error ("Cannot divide by zero", E_USER_ERROR);
</programlisting>
</informalexample>
<note>
<para>
See <function>set_error_handler</function> for a more extensive example.
</para>
</note>
</para>
<para>
See also <function>error_reporting</function>,
<function>set_error_handler</function>,
<function>restore_error_handler</function>,
<function>user_error</function>
</para>
</refsect1>
</refentry>
<refentry id="function.user-error">
<refnamediv>
<refname>user_error</refname>
<refpurpose>
Generates a user-level error/warning/notice message
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>user_error</function></funcdef>
<paramdef>string <parameter>error_msg</parameter></paramdef>
<paramdef>int
<parameter><optional>error_type</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
This is an alias for the function <function>trigger_error</function>.
</para>
<para>
See also <function>error_reporting</function>,
<function>set_error_handler</function>,
<function>restore_error_handler</function>, and
<function>trigger_error</function>
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
Index: phpdoc/hu/functions/funchand.xml
+++ phpdoc/hu/functions/funchand.xml
<reference id="ref.funchand">
<title>Function Handling functions</title>
<titleabbrev>Functions</titleabbrev>
<partintro>
<para>
These functions all handle various operations involved in working
with functions.
</para>
</partintro>
<refentry id="function.call-user-func">
<refnamediv>
<refname>call_user_func</refname>
<refpurpose>
Call a user function given by the first parameter
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>mixed
<function>call_user_func</function>
</funcdef>
<paramdef>string
<parameter>function_name</parameter>
</paramdef>
<paramdef>mixed
<parameter><optional>parameter</optional></parameter>
</paramdef>
<paramdef>mixed
<parameter><optional>...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Call a user defined function given by the
<parameter>function_name</parameter> parameter. Take the
following:
<informalexample>
<programlisting role="php">
function barber ($type) {
print "You wanted a $type haircut, no problem";
}
call_user_func ('barber', "mushroom");
call_user_func ('barber', "shave");
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.create-function">
<refnamediv>
<refname>create_function</refname>
<refpurpose>Create an anonymous (lambda-style) function</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>string <function>create_function</function></funcdef>
<paramdef>string <parameter>args</parameter></paramdef>
<paramdef>string <parameter>code</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Creates an anonymous function from the parameters passed, and
returns a unique name for it. Usually the
<parameter>args</parameter> will be passed as a single quote
delimited string, and this is also recommended for the
<parameter>code</parameter>. The reason for using single quoted
strings, is to protect
the variable names from parsing, otherwise, if you use double
quotes there will be a need to escape the variable names, e.g.
<literal>\$avar</literal>.
</para>
<para>
You can use this function, to (for example) create a function
from information gathered at run time:
<example>
<title>
Creating an anonymous function with <function>create_function</function>
</title>
<programlisting role="php">
$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
of operations to a list of parameters:
<example>
<title>
Making a general processing function with
<function>create_function</function>
</title>
<programlisting role="php">
function process($var1, $var2, $farr) {
for ($f=0; $f < count($farr); $f++)
echo $farr[$f]($var1,$var2)."\n";
}
// create a bunch of math functions
$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;}';
$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);'),
create_function('$a,$b', $f1),
create_function('$a,$b', $f2),
create_function('$a,$b', $f3)
);
echo "\nUsing the first array of anonymous functions\n";
echo "parameters: 2.3445, M_PI\n";
process(2.3445, M_PI, $farr);
// now make a bunch of string processing functions
$garr = array(
create_function('$b,$a','if (strncmp($a,$b,3) == 0) return "** \"$a\" '.
'and \"$b\"\n** Look the same to me! (looking at the first 3 chars)";'),
create_function('$a,$b','; return "CRCs: ".crc32($a)." , ".crc32(b);'),
create_function('$a,$b','; return "similar(a,b) = ".similar_text($a,$b,&$p)."($p%)";')
);
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>
Using the first array of anonymous functions
parameters: 2.3445, M_PI
some trig: -1.6291725057799
a hypotenuse: 3.9199852871011
b*a^2 = 4.8103313314525
min(b^2+a, a^2,b) = 8.6382729035898
ln(a/b) = 0.27122299212594
Using the second array of anonymous functions
** "Twas the night" and "Twas brilling and the slithy toves"
** 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
is to create callback functions, for example when using
<function>array_walk</function> or <function>usort</function>
<example>
<title>Using anonymous functions as callback functions</title>
<programlisting role="php">
$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
// )
// an array of strings ordered from shorter to longer
$sv = array("small","larger","a big string","it is a string thing");
print_r($sv);
// outputs:
// Array
// (
// [0] => small
// [1] => larger
// [2] => a big string
// [3] => it is a string thing
// )
// sort it from longer to shorter
usort($sv, create_function('$a,$b','return strlen($b) - strlen($a);'));
print_r($sv);
// outputs:
// Array
// (
// [0] => it is a string thing
// [1] => a big string
// [2] => larger
// [3] => small
// )
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.func-get-arg">
<refnamediv>
<refname>func_get_arg</refname>
<refpurpose>Return an item from the argument list</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>func_get_arg</function></funcdef>
<paramdef>int <parameter>arg_num</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Returns the argument which is at the
<parameter>arg_num</parameter>'th offset into a user-defined
function's argument list. Function arguments are counted starting
from zero. <function>Func_get_arg</function> will generate a
warning if called from outside of a function definition.
</simpara>
<simpara>
If <parameter>arg_num</parameter> is greater than the number of
arguments actually passed, a warning will be generated and
<function>func_get_arg</function> will return FALSE.
</simpara>
<para>
<informalexample>
<programlisting role="php">
<?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";
}
}
foo (1, 2, 3);
?>
</programlisting>
</informalexample>
</para>
<simpara>
<function>Func_get_arg</function> may be used in conjunction with
<function>func_num_args</function> and
<function>func_get_args</function> to allow user-defined
functions to accept variable-length argument lists.
</simpara>
<note>
<simpara>
This function was added in PHP 4.
</simpara>
</note>
</refsect1>
</refentry>
<refentry id="function.func-get-args">
<refnamediv>
<refname>func_get_args</refname>
<refpurpose>
Returns an array comprising a function's argument list
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>func_get_args</function></funcdef>
<paramdef>void <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Returns an array in which each element is the corresponding
member of the current user-defined function's argument
list. <function>Func_get_args</function> will generate a warning
if called from outside of a function definition.
</simpara>
<para>
<informalexample>
<programlisting role="php">
<?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";
}
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
echo "Argument $i is: " . $arg_list[$i] . "<br>\n";
}
}
foo (1, 2, 3);
?>
</programlisting>
</informalexample>
</para>
<simpara>
<function>Func_get_args</function> may be used in conjunction
with <function>func_num_args</function> and
<function>func_get_arg</function> to allow user-defined functions
to accept variable-length argument lists.
</simpara>
<note>
<simpara>
This function was added in PHP 4.
</simpara>
</note>
</refsect1>
</refentry>
<refentry id="function.func-num-args">
<refnamediv>
<refname>func_num_args</refname>
<refpurpose>
Returns the number of arguments passed to the function
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>func_num_args</function></funcdef>
<paramdef>void <parameter></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Returns the number of arguments passed into the current
user-defined function. <function>Func_num_args</function> will
generate a warning if called from outside of a function
definition.
</simpara>
<para>
<informalexample>
<programlisting role="php">
<?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>
<simpara>
<function>Func_num_args</function> may be used in conjunction
with <function>func_get_arg</function> and
<function>func_get_args</function> to allow user-defined
functions to accept variable-length argument lists.
</simpara>
<note>
<simpara>
This function was added in PHP 4.
</simpara>
</note>
</refsect1>
</refentry>
<refentry id="function.function-exists">
<refnamediv>
<refname>function_exists</refname>
<refpurpose>
Return true if the given function has been defined
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>function_exists</function></funcdef>
<paramdef>string <parameter>function_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Checks the list of defined functions for
<parameter>function_name</parameter>. Returns true if the given
function name was found, false otherwise.
</simpara>
</refsect1>
</refentry>
<refentry id="function.register-shutdown-function">
<refnamediv>
<refname>register_shutdown_function</refname>
<refpurpose>
Register a function for execution on shutdown
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int
<function>register_shutdown_function</function>
</funcdef>
<paramdef>string <parameter>func</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Registers the function named by <parameter>func</parameter> to be
executed when script processing is complete.</simpara>
<para>
Common Pitfalls:
</para>
<simpara>
Since no output is allowed to the browser in this function, you
will be unable to debug it using statements such as print or
echo.
</simpara>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
Index: phpdoc/hu/functions/satellite.xml
+++ phpdoc/hu/functions/satellite.xml
<!--
$Id: satellite.xml,v 1.1 2000/09/17 22:50:00 rasmus Exp $
Author: David Eriksson <david <email protected>>
-->
<reference id="ref.satellite">
<title>Satellite CORBA client extension</title>
<titleabbrev>Satellite</titleabbrev>
<partintro>
<para>
The Satellite extension is used for accessing CORBA objects. You
will need to set the idl_directory= entry in php.ini to a path
where you store all IDL files you use.
</para>
</partintro>
<refentry id="class.orbitobject">
<refnamediv>
<refname>OrbitObject</refname>
<refpurpose>Access CORBA objects</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>new <function>OrbitObject</function></funcdef>
<paramdef>string <parameter>ior</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This class provides access to a CORBA object. The
<parameter>ior</parameter> parameter should be a string
containing the IOR (Interoperable Object Reference) that
identifies the remote object.
</para>
<para>
<example>
<title>Sample IDL file</title>
<programlisting>
interface MyInterface {
void SetInfo (string info);
string GetInfo();
attribute int value;
}
</programlisting>
</example>
</para>
<para>
<example>
<title>PHP code for accessing MyInterface</title>
<programlisting role="php">
<?php
$obj = new OrbitObject ($ior);
$obj->SetInfo ("A 2GooD object");
echo $obj->GetInfo();
$obj->value = 42;
echo $obj->value;
?>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="class.orbitenum">
<refnamediv>
<refname>OrbitEnum</refname>
<refpurpose>Use CORBA enums</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>new <function>OrbitEnum</function></funcdef>
<paramdef>string <parameter>id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This class represents the enumeration identified with the
<parameter>id</parameter> parameter. The
<parameter>id</parameter> can be either the name of the
enumeration (e.g "MyEnum"), or the full repository id
(e.g. "IDL:MyEnum:1.0").
</para>
<para>
<example>
<title>Sample IDL file</title>
<programlisting>
enum MyEnum {
a,b,c,d,e
};
</programlisting>
</example>
</para>
<para>
<example>
<title>PHP code for accessing MyEnum</title>
<programlisting role="php">
<?php
$enum = new OrbitEnum ("MyEnum");
echo $enum->a; /* write 0 */
echo $enum->c; /* write 2 */
echo $enum->e; /* write 4 */
?>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="class.orbitstruct">
<refnamediv>
<refname>OrbitStruct</refname>
<refpurpose>Use CORBA structs</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>new <function>OrbitStruct</function></funcdef>
<paramdef>string <parameter>id</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This class represents the structure identified with the
<parameter>id</parameter> parameter. The
<parameter>id</parameter> can be either the name of the struct
(e.g "MyStruct"), or the full repository id
(e.g. "IDL:MyStruct:1.0").
</para>
<para>
<example>
<title>Sample IDL file</title>
<programlisting>
struct MyStruct {
short shortvalue;
string stringvalue;
};
interface SomeInterface {
void SetValues (MyStruct values);
MyStruct GetValues();
}
</programlisting>
</example>
</para>
<para>
<example>
<title>PHP code for accessing MyStruct</title>
<programlisting role="php">
<?php
$obj = new OrbitObject ($ior);
$initial_values = new OrbitStruct ("IDL:MyStruct:1.0");
$initial_values->shortvalue = 42;
$initial_values->stringvalue = "HGTTG";
$obj->SetValues ($initial_values);
$values = $obj->GetValues();
echo $values->shortvalue;
echo $values->stringvalue;
?>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.satellite_caught_exception">
<refnamediv>
<refname>satellite_caught_exception</refname>
<refpurpose>
See if an exception was caught from the previous function
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>bool
<function>satellite_caught_exception</function>
</funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns true if an exception has been caught.
</para>
<para>
<example>
<title>Sample IDL file</title>
<programlisting>
/* ++?????++ Out of Cheese Error. Redo From Start. */
exception OutOfCheeseError {
int parameter;
}
interface AnotherInterface {
void AskWhy() raises (OutOfCheeseError);
}
</programlisting>
</example>
</para>
<para>
<example>
<title>PHP code for handling CORBA exceptions</title>
<programlisting role="php">
<?php
$obj = new OrbitObject ($ior);
$obj->AskWhy();
if (satellite_caught_exception()) {
if ("IDL:OutOfCheeseError:1.0" == satellite_exception_id()) {
$exception = satellite_exception_value();
echo $exception->parameter;
}
}
?>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.satellite_exception_id">
<refnamediv>
<refname>satellite_exception_id</refname>
<refpurpose>Get the repository id for the latest excetpion.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>string <function>satellite_exception_id</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Return a repository id string. (E.g. "IDL:MyException:1.0".) For
example usage see
<function>satellite_caught_exception</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.satellite_exception_value">
<refnamediv>
<refname>satellite_exception_value</refname>
<refpurpose>
Get the exception struct for the latest exception
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>OrbitStruct
<function>satellite_exception_value</function>
</funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Return an exception struct. For example usage see
<function>satellite_caught_exception</function>.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
- Next message: Andrei Zmievski: "Re: [PHP-DOC] cvs: phpdoc /en/appendices debugger.xml phpdevel.xml /en/chapters intro.xml /en/features file-upload.xml /en/functions array.xml com.xml cpdf.xml cybercash.xml domxml.xml errorfunc.xml funchand.xml http.xml ibase.xml image.xml imap.xml info.xml math.xml misc.xml pdf.xml posix.xml recode.xml swf.xml /en/language control-structures.xml functions.xml operators.xml types.xml variables.xml"
- Previous message: Martin Samesch: "[PHP-DOC] cvs: phpdoc /de/functions cpdf.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

