CS : Function declarations follow the 'one true brace' convention

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@148756 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2004-01-15 12:43:50 +00:00
parent 830cccc0be
commit 45a0f65851
77 changed files with 476 additions and 280 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
<refentry id="function.array-diff-uassoc">
<refnamediv>
@ -33,8 +33,11 @@
<programlisting role="php">
<![CDATA[
<?php
function key_compare_func($a, $b) {
if ($a === $b) return 0;
function key_compare_func($a, $b)
{
if ($a === $b) {
return 0;
}
return ($a > $b)? 1:-1;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.62 -->
<refentry id="function.array-filter">
<refnamediv>
@ -29,11 +29,13 @@
<programlisting role="php">
<![CDATA[
<?php
function odd($var) {
function odd($var)
{
return($var % 2 == 1);
}
function even($var) {
function even($var)
{
return($var % 2 == 0);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- $Revision: 1.11 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.62 -->
<refentry id="function.array-map">
<refnamediv>
@ -31,7 +31,8 @@
<programlisting role="php">
<![CDATA[
<?php
function cube($n) {
function cube($n)
{
return($n * $n * $n);
}
@ -64,11 +65,13 @@ Array
<programlisting role="php">
<![CDATA[
<?php
function show_Spanish($n, $m) {
function show_Spanish($n, $m)
{
return("The number $n is called $m in Spanish");
}
function map_Spanish($n, $m) {
function map_Spanish($n, $m)
{
return(array($n => $m));
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.array-reduce">
<refnamediv>
@ -31,12 +31,14 @@
<programlisting role="php">
<![CDATA[
<?php
function rsum($v, $w) {
function rsum($v, $w)
{
$v += $w;
return $v;
}
function rmul($v, $w) {
function rmul($v, $w)
{
$v *= $w;
return $v;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
<refentry id="function.array-udiff-assoc">
<refnamediv>
@ -34,14 +34,18 @@
<?php
class cr {
var $priv_member;
function cr($val) {
function cr($val)
{
$this->priv_member = $val;
}
function comp_func_cr($a, $b) {
function comp_func_cr($a, $b)
{
if ($a->priv_member === $b->priv_member) return 0;
return ($a->priv_member > $b->priv_member)? 1:-1;
}
}
$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),);
$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
<refentry id="function.array-udiff-uassoc">
<refnamediv>
@ -39,14 +39,19 @@
<?php
class cr {
var $priv_member;
function cr($val) {
function cr($val)
{
$this->priv_member = $val;
}
function comp_func_cr($a, $b) {
function comp_func_cr($a, $b)
{
if ($a->priv_member === $b->priv_member) return 0;
return ($a->priv_member > $b->priv_member)? 1:-1;
}
function comp_func_key($a, $b) {
function comp_func_key($a, $b)
{
if ($a === $b) return 0;
return ($a > $b)? 1:-1;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
<refentry id="function.array-udiff">
<refnamediv>
@ -35,10 +35,13 @@
<?php
class cr {
var $priv_member;
function cr($val) {
function cr($val)
{
$this->priv_member = $val;
}
function comp_func_cr($a, $b) {
function comp_func_cr($a, $b)
{
if ($a->priv_member === $b->priv_member) return 0;
return ($a->priv_member > $b->priv_member)? 1:-1;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.array-walk">
<refnamediv>
@ -77,11 +77,13 @@
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
function test_alter(&$item1, $key, $prefix) {
function test_alter(&$item1, $key, $prefix)
{
$item1 = "$prefix: $item1";
}
function test_print($item2, $key) {
function test_print($item2, $key)
{
echo "$key. $item2<br />\n";
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- $Revision: 1.12 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.uksort">
<refnamediv>
@ -38,7 +38,8 @@
<programlisting role="php">
<![CDATA[
<?php
function cmp($a, $b) {
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<!-- $Revision: 1.17 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.usort">
<refnamediv>
@ -46,7 +46,8 @@
<programlisting role="php">
<![CDATA[
<?php
function cmp($a, $b) {
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}
@ -91,7 +92,8 @@ while (list($key, $value) = each($a)) {
<programlisting role="php">
<![CDATA[
<?php
function cmp($a, $b) {
function cmp($a, $b)
{
return strcmp($a["fruit"], $b["fruit"]);
}
@ -135,12 +137,14 @@ $fruits[2]: lemons
class TestObj {
var $name;
function TestObj($name) {
function TestObj($name)
{
$this->name = $name;
}
/* This is the static comparing function: */
function cmp_obj($a, $b) {
function cmp_obj($a, $b)
{
$al = strtolower($a->name);
$bl = strtolower($b->name);
if ($al == $bl) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 -->
<refentry id="function.call-user-method">
<refnamediv>
@ -40,12 +40,14 @@ class Country {
var $NAME;
var $TLD;
function Country($name, $tld) {
function Country($name, $tld)
{
$this->NAME = $name;
$this->TLD = $tld;
}
function print_info($prestr = "") {
function print_info($prestr = "")
{
echo $prestr . "Country: " . $this->NAME . "\n";
echo $prestr . "Top Level Domain: " . $this->TLD . "\n";
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.2 -->
<refentry id="function.get-class-methods">
<refnamediv>
@ -40,17 +40,20 @@ $class_methods = get_class_methods($my_class); // see below the full example
class myclass {
// constructor
function myclass() {
function myclass()
{
return(true);
}
// method 1
function myfunc1() {
function myfunc1()
{
return(true);
}
// method 2
function myfunc2() {
function myfunc2()
{
return(true);
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 -->
<refentry id="function.get-class">
<refnamediv>
@ -32,11 +32,13 @@
<?php
class foo {
function foo() {
function foo()
{
// implements some logic
}
function name() {
function name()
{
echo "My name is " , get_class($this) , "\n";
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.1 -->
<refentry id="function.get-object-vars">
<refnamediv>
@ -35,16 +35,19 @@ class Point2D {
var $x, $y;
var $label;
function Point2D($x, $y) {
function Point2D($x, $y)
{
$this->x = $x;
$this->y = $y;
}
function setLabel($label) {
function setLabel($label)
{
$this->label = $label;
}
function getPoint() {
function getPoint()
{
return array("x" => $this->x,
"y" => $this->y,
"label" => $this->label);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 -->
<refentry id="function.get-parent-class">
<refnamediv>
@ -30,19 +30,22 @@
<?php
class dad {
function dad() {
function dad()
{
// implements some logic
}
}
class child extends dad {
function child() {
function child()
{
echo "I'm " , get_parent_class($this) , "'s son\n";
}
}
class child2 extends dad {
function child2() {
function child2()
{
echo "I'm " , get_parent_class('child2') , "'s son too\n";
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- $Revision: 1.12 $ -->
<reference id="ref.classobj">
<title>Class/Object Functions</title>
<titleabbrev>Classes/Objects</titleabbrev>
@ -64,16 +64,19 @@ class Vegetable {
var $edible;
var $color;
function Vegetable($edible, $color="green") {
function Vegetable($edible, $color="green")
{
$this->edible = $edible;
$this->color = $color;
}
function is_edible() {
function is_edible()
{
return $this->edible;
}
function what_color() {
function what_color()
{
return $this->color;
}
@ -84,15 +87,18 @@ class Spinach extends Vegetable {
var $cooked = false;
function Spinach() {
function Spinach()
{
$this->Vegetable(true, "green");
}
function cook_it() {
function cook_it()
{
$this->cooked = true;
}
function is_cooked() {
function is_cooked()
{
return $this->cooked;
}
@ -121,19 +127,22 @@ include "classes.inc";
// utility functions
function print_vars($obj) {
function print_vars($obj)
{
$arr = get_object_vars($obj);
while (list($prop, $val) = each($arr))
echo "\t$prop = $val\n";
}
function print_methods($obj) {
function print_methods($obj)
{
$arr = get_class_methods(get_class($obj));
foreach ($arr as $method)
echo "\tfunction $method()\n";
}
function class_parentage($obj, $class) {
function class_parentage($obj, $class)
{
if (is_subclass_of($GLOBALS[$obj], $class)) {
echo "Object $obj belongs to class " . get_class($$obj);
echo " a subclass of $class\n";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/datetime.xml, last change in rev 1.2 -->
<refentry id="function.microtime">
<refnamediv>
@ -43,7 +43,8 @@
<![CDATA[
<?php
function getmicrotime() {
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.19 $ -->
<!-- $Revision: 1.20 $ -->
<reference id="ref.dba">
<title>Database (dbm-style) abstraction layer functions</title>
<titleabbrev>dba</titleabbrev>
@ -241,8 +241,9 @@ 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);
}
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/dbx.xml, last change in rev 1.3 -->
<refentry id="function.dbx-compare">
<refnamediv>
@ -69,7 +69,8 @@
<programlisting role="php">
<![CDATA[
<?php
function user_re_order($a, $b) {
function user_re_order($a, $b)
{
$rv = dbx_compare($a, $b, "parentid", DBX_CMP_DESC);
if (!$rv) {
$rv = dbx_compare($a, $b, "id", DBX_CMP_NUMBER);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/dbx.xml, last change in rev 1.3 -->
<refentry id="function.dbx-sort">
<refnamediv>
@ -30,7 +30,8 @@
<programlisting role="php">
<![CDATA[
<?php
function user_re_order($a, $b) {
function user_re_order($a, $b)
{
$rv = dbx_compare($a, $b, "parentid", DBX_CMP_DESC);
if (!$rv) {
$rv = dbx_compare($a, $b, "id", DBX_CMP_NUMBER);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<section id="errorfunc.examples">
&reftitle.examples;
<para>
@ -16,7 +16,8 @@
error_reporting(0);
// user defined error handling function
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
// timestamp for the error entry
$dt = date("Y-m-d H:i:s (T)");
@ -61,7 +62,8 @@ function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
}
function distance($vect1, $vect2) {
function distance($vect1, $vect2)
{
if (!is_array($vect1) || !is_array($vect2)) {
trigger_error("Incorrect parameters, arrays expected", E_USER_ERROR);
return NULL;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.debug-backtrace">
<refnamediv>
<refname>debug_backtrace</refname>
@ -94,7 +94,8 @@
// filename: a.php
<?php
function a_test($str) {
function a_test($str)
{
echo "\nHi: $str";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.17 $ -->
<!-- $Revision: 1.18 $ -->
<!-- splitted from ./en/functions/errorfunc.xml, last change in rev 1.1 -->
<refentry id="function.set-error-handler">
<refnamediv>
@ -67,7 +67,8 @@ define("WARNING", E_USER_NOTICE);
error_reporting(FATAL | ERROR | WARNING);
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline) {
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case FATAL:
echo "<b>FATAL</b> [$errno] $errstr<br />\n";
@ -89,7 +90,8 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
}
// function to test the error handling
function scale_by_log($vect, $scale) {
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);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/fdf.xml, last change in rev 1.2 -->
<refentry id="function.fdf-next-field-name">
<refnamediv>
@ -25,12 +25,12 @@
<programlisting role="php">
<![CDATA[
<?php
$fdf = fdf_open($HTTP_FDF_DATA);
for ($field = fdf_next_field_name($fdf);
$field != "";
$field = fdf_next_field_name($fdf, $field)) {
echo "field: $field\n";
}
$fdf = fdf_open($HTTP_FDF_DATA);
for ($field = fdf_next_field_name($fdf);
$field != "";
$field = fdf_next_field_name($fdf, $field)) {
echo "field: $field\n";
}
?>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.39 -->
<refentry id="function.is-uploaded-file">
<refnamediv>
@ -41,7 +41,8 @@
<![CDATA[
<?php
/* Userland test for uploaded file. */
function is_uploaded_file($filename) {
function is_uploaded_file($filename)
{
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
$tmp_file = dirname(tempnam('', ''));
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.10 -->
<refentry id="function.call-user-func-array">
<refnamediv>
@ -26,7 +26,8 @@
<programlisting role="php">
<![CDATA[
<?php
function debug($var, $val) {
function debug($var, $val)
{
echo "***DEBUGGING\nVARIABLE: $var\nVALUE:";
if (is_array($val) || is_object($val) || is_resource($val)) {
print_r($val);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 -->
<refentry id="function.call-user-func">
<refnamediv>
@ -26,7 +26,8 @@
<programlisting role="php">
<![CDATA[
<?php
function barber($type) {
function barber($type)
{
echo "You wanted a $type haircut, no problem";
}
call_user_func('barber', "mushroom");
@ -47,7 +48,8 @@ call_user_func('barber', "shave");
<![CDATA[
<?php
class myclass {
function say_hello() {
function say_hello()
{
echo "Hello!\n";
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 -->
<refentry id="function.create-function">
<refnamediv>
@ -60,9 +60,11 @@ echo $newfunc(2, M_E) . "\n";
<programlisting role="php">
<![CDATA[
<?php
function process($var1, $var2, $farr) {
for ($f=0; $f < count($farr); $f++)
function process($var1, $var2, $farr)
{
for ($f=0; $f < count($farr); $f++) {
echo $farr[$f]($var1, $var2) . "\n";
}
}
// create a bunch of math functions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 -->
<refentry id="function.func-get-arg">
<refnamediv>
@ -29,7 +29,8 @@
<programlisting role="php">
<![CDATA[
<?php
function foo() {
function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs<br />\n";
if ($numargs >= 2) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 -->
<refentry id="function.func-get-args">
<refnamediv>
@ -25,7 +25,8 @@
<programlisting role="php">
<![CDATA[
<?php
function foo() {
function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs<br />\n";
if ($numargs >= 2) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 -->
<refentry id="function.func-num-args">
<refnamediv>
@ -24,7 +24,8 @@
<programlisting role="php">
<![CDATA[
<?php
function foo() {
function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs\n";
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/funchand.xml, last change in rev 1.6 -->
<refentry id="function.get-defined-functions">
<refnamediv>
@ -26,7 +26,8 @@
<programlisting role="php">
<![CDATA[
<?php
function myrow($id, $data) {
function myrow($id, $data)
{
return "<tr><th>$id</th><td>$data</td></tr>\n";
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<reference id="ref.gmp">
<title>GMP functions</title>
<titleabbrev>GMP</titleabbrev>
@ -74,7 +74,8 @@
<programlisting role="php">
<![CDATA[
<?php
function fact($x) {
function fact($x)
{
if ($x <= 1) {
return 1;
} else {

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1' ?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/hwapi.xml, last change in rev 1.1 -->
<refentry id="function.hwapi-object">
<refnamediv>
@ -30,7 +30,8 @@
<programlisting role="php">
<![CDATA[
<?php
function handle_error($error) {
function handle_error($error)
{
$reason = $error->reason(0);
echo "Type: <b>";
switch ($reason->type()) {
@ -48,7 +49,8 @@ function handle_error($error) {
echo "Description: " . $reason->description("en") . "<br />\n";
}
function list_attr($obj) {
function list_attr($obj)
{
echo "<table>\n";
$count = $obj->count();
for ($i=0; $i<$count; $i++) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.ibase-set-event-handler">
<refnamediv>
<refname>ibase_set_event_handler</refname>
@ -29,17 +29,18 @@
<![CDATA[
<?php
function event_handler($event_name, $link) {
if ($event_name=="NEW ORDER") {
// process new order
ibase_query($link, "UPDATE orders SET status='handled'");
} else if ($event_name=="DB_SHUTDOWN") {
// free event handler
return false;
}
function event_handler($event_name, $link)
{
if ($event_name=="NEW ORDER") {
// process new order
ibase_query($link, "UPDATE orders SET status='handled'");
} else if ($event_name=="DB_SHUTDOWN") {
// free event handler
return false;
}
}
ibase_set_event_handler($link, "event_handler", "NEW_ORDER", "DB_SHUTDOWN");
ibase_set_event_handler($link, "event_handler", "NEW_ORDER", "DB_SHUTDOWN");
?>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.2 -->
<refentry id="function.imagecreatefromgif">
<refnamediv>
@ -29,7 +29,8 @@
<programlisting role="php">
<![CDATA[
<?php
function LoadGif ($imgname) {
function LoadGif ($imgname)
{
$im = @imagecreatefromgif ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (150, 30); /* Create a blank image */

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.4 -->
<refentry id="function.imagecreatefromjpeg">
<refnamediv>
@ -29,7 +29,8 @@
<programlisting role="php">
<![CDATA[
<?php
function LoadJpeg($imgname) {
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate(150, 30); /* Create a blank image */

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.4 -->
<refentry id="function.imagecreatefrompng">
<refnamediv>
@ -29,7 +29,8 @@
<programlisting role="php">
<![CDATA[
<?php
function LoadPNG($imgname) {
function LoadPNG($imgname)
{
$im = @imagecreatefrompng($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate(150, 30); /* Create a blank image */

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.30 -->
<refentry id="function.imagecreatefromwbmp">
<refnamediv>
@ -29,7 +29,8 @@
<programlisting role="php">
<![CDATA[
<?php
function LoadWBMP($imgname) {
function LoadWBMP($imgname)
{
$im = @imagecreatefromwbmp($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (20, 20); /* Create a blank image */

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.2 -->
<refentry id="function.imageline">
<refnamediv>
@ -29,7 +29,8 @@
<![CDATA[
<?php
function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1) {
function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1)
{
/* this way it works well only for orthogonal lines
imagesetthickness($image, $thick);
return imageline($image, $x1, $y1, $x2, $y2, $color);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/info.xml, last change in rev 1.51 -->
<refentry id="function.assert">
<refnamediv>
@ -81,7 +81,8 @@ assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);
// Create a handler function
function my_assert_handler($file, $line, $code) {
function my_assert_handler($file, $line, $code)
{
echo "<hr>Assertion Failed:
File '$file'<br />
Line '$line'<br />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ldap.xml, last change in rev 1.2 -->
<refentry id="function.ldap-get-attributes">
<refnamediv>
@ -58,8 +58,9 @@ $attrs = ldap_get_attributes($ds, $entry);
echo $attrs["count"] . " attributes held for this entry:<p>";
for ($i=0; $i<$attrs["count"]; $i++)
for ($i=0; $i<$attrs["count"]; $i++) {
echo $attrs[$i] . "<br />";
}
?>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ldap.xml, last change in rev 1.2 -->
<refentry id="function.ldap-get-values">
<refnamediv>
@ -63,10 +63,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.<br />";
for ($i=0; $i < $values["count"]; $i++)
for ($i=0; $i < $values["count"]; $i++) {
echo $values[$i] . "<br />";
}
?>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/ldap.xml, last change in rev 1.2 -->
<refentry id="function.ldap-list">
<refnamediv>
@ -58,8 +58,10 @@ $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>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.mt-srand">
<refnamediv>
@ -22,7 +22,8 @@
<![CDATA[
<?php
// seed with microseconds
function make_seed() {
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.srand">
<refnamediv>
@ -22,7 +22,8 @@
<![CDATA[
<?php
// seed with microseconds
function make_seed() {
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ming.xml, last change in rev 1.24 -->
<refentry id="function.swfbutton">
<refnamediv>
@ -37,7 +37,8 @@
$p = new SWFSprite();
function label($string) {
function label($string)
{
global $f;
$t = new SWFTextField();
@ -48,7 +49,8 @@
return $t;
}
function addLabel($string) {
function addLabel($string)
{
global $p;
$i = $p->add(label($string));
@ -66,7 +68,8 @@
addLabel("SWFBUTTON_DRAGOVER");
addLabel("SWFBUTTON_DRAGOUT");
function rect($r, $g, $b) {
function rect($r, $g, $b)
{
$s = new SWFShape();
$s->setRightFill($s->addFill($r, $g, $b));
$s->drawLine(600, 0);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ming.xml, last change in rev 1.24 -->
<refentry id="function.swfdisplayitem.rotateto">
<refnamediv>
@ -43,7 +43,8 @@
// functions with huge numbers of arbitrary
// arguments are always a good idea! Really!
function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string) {
function text($r, $g, $b, $a, $rot, $x, $y, $scale, $string)
{
global $f, $m;
$t = new SWFText();
@ -71,7 +72,8 @@
return $i;
}
function step($i) {
function step($i)
{
$oldrot = $i->rot;
$i->rot = 19*$i->rot/20;
$i->x = (19*$i->x + 1200)/20;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<refentry id="function.aggregate-info">
<refnamediv>
<refname>aggregate_info</refname>
@ -30,11 +30,13 @@
class Slicer {
var $vegetable;
function Slicer($vegetable) {
function Slicer($vegetable)
{
$this->vegetable = $vegetable;
}
function slice_it($num_cuts) {
function slice_it($num_cuts)
{
echo "Doing some simple slicing\n";
for ($i=0; $i < $num_cuts; $i++) {
// do some slicing
@ -46,11 +48,13 @@ class Dicer {
var $vegetable;
var $rotation_angle = 90; // degrees
function Dicer($vegetable) {
function Dicer($vegetable)
{
$this->vegetable = $vegetable;
}
function dice_it($num_cuts) {
function dice_it($num_cuts)
{
echo "Cutting in one direction\n";
for ($i=0; $i < $num_cuts; $i++) {
// do some cutting
@ -62,11 +66,13 @@ class Dicer {
}
}
function rotate($deg) {
function rotate($deg)
{
echo "Now rotating {$this->vegetable} {$deg} degrees\n";
}
function _secret_super_dicing($num_cuts) {
function _secret_super_dicing($num_cuts)
{
// so secret we cannot show you ;-)
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<reference id="ref.objaggregation">
<title>Object Aggregation/Composition Functions</title>
<titleabbrev>Object Aggregation</titleabbrev>
@ -31,11 +31,13 @@
<?php
class DateTime {
function DateTime() {
function DateTime()
{
// empty constructor
}
function now() {
function now()
{
return date("Y-m-d H:i:s");
}
}
@ -44,12 +46,14 @@ class Report {
var $_dt;
// more properties ...
function Report() {
function Report()
{
$this->_dt = new DateTime();
// initialization code ...
}
function generateReport() {
function generateReport()
{
$dateTime = $_dt->now();
// more code ...
}
@ -78,11 +82,13 @@ class DateTime {
class DateTimePlus {
var $_format;
function DateTimePlus($format="Y-m-d H:i:s") {
function DateTimePlus($format="Y-m-d H:i:s")
{
$this->_format = $format;
}
function now() {
function now()
{
return date($this->_format);
}
}
@ -91,15 +97,18 @@ class Report {
var $_dt; // we'll keep the reference to DateTime here
// more properties ...
function Report() {
function Report()
{
// do some initialization
}
function setDateTime(&$dt) {
function setDateTime(&$dt)
{
$this->_dt =& $dt;
}
function generateReport() {
function generateReport()
{
$dateTime = $this->_dt->now();
// more code ...
}
@ -161,10 +170,13 @@ $output = $rep->generateReport();
class FileStorage {
var $data;
function FileStorage($data) {
function FileStorage($data)
{
$this->data = $data;
}
function write($name) {
function write($name)
{
$fp = fopen(name, "w");
fwrite($fp, $this->data);
fclose($data);
@ -176,12 +188,14 @@ class WDDXStorage {
var $version = "1.0";
var $_id; // "private" variable
function WDDXStorage($data) {
function WDDXStorage($data)
{
$this->data = $data;
$this->_id = $this->_genID();
}
function store() {
function store()
{
if ($this->_id) {
$pid = wddx_packet_start($this->_id);
wddx_add_vars($pid, "this->data");
@ -195,7 +209,8 @@ class WDDXStorage {
}
// a private method
function _genID() {
function _genID()
{
return md5(uniqid(rand(), true));
}
}
@ -204,11 +219,13 @@ class DBStorage {
var $data;
var $dbtype = "mysql";
function DBStorage($data) {
function DBStorage($data)
{
$this->data = $data;
}
function save() {
function save()
{
$dbh = mysql_connect();
mysql_select_db("storage", $dbh);
$serdata = serialize($this->data);
@ -237,13 +254,15 @@ include "storageclasses.inc";
// some utilty functions
function p_arr($arr) {
function p_arr($arr)
{
foreach ($arr as $k => $v)
$out[] = "\t$k => $v";
return implode("\n", $out);
}
function object_info($obj) {
function object_info($obj)
{
$out[] = "Class: " . get_class($obj);
foreach (get_object_vars($obj) as $var=>$val) {
if (is_array($val)) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 -->
<refentry id="function.ocilogon">
<refnamediv>
@ -41,42 +41,49 @@ $db = "";
$c1 = ocilogon("scott", "tiger", $db);
$c2 = ocilogon("scott", "tiger", $db);
function create_table($conn) {
function create_table($conn)
{
$stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))");
ociexecute($stmt);
echo $conn . " created table\n\n";
}
function drop_table($conn) {
function drop_table($conn)
{
$stmt = ociparse($conn, "drop table scott.hallo");
ociexecute($stmt);
echo $conn . " dropped table\n\n";
}
function insert_data($conn) {
function insert_data($conn)
{
$stmt = ociparse($conn, "insert into scott.hallo
values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . " inserted hallo\n\n";
}
function delete_data($conn) {
function delete_data($conn)
{
$stmt = ociparse($conn, "delete from scott.hallo");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . " deleted hallo\n\n";
}
function commit($conn) {
function commit($conn)
{
ocicommit($conn);
echo $conn . " committed\n\n";
}
function rollback($conn) {
function rollback($conn)
{
ocirollback($conn);
echo $conn . " rollback\n\n";
}
function select_data($conn) {
function select_data($conn)
{
$stmt = ociparse($conn, "select * from scott.hallo");
ociexecute($stmt, OCI_DEFAULT);
echo $conn."----selecting\n\n";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/oci8.xml, last change in rev 1.15 -->
<refentry id="function.ocinlogon">
<refnamediv>
@ -45,43 +45,50 @@ $db = "";
$c1 = ocilogon("scott", "tiger", $db);
$c2 = ocinlogon("scott", "tiger", $db);
function create_table($conn) {
function create_table($conn)
{
$stmt = ociparse($conn, "create table scott.hallo (test
varchar2(64))");
ociexecute($stmt);
echo $conn . " created table\n\n";
}
function drop_table($conn) {
function drop_table($conn)
{
$stmt = ociparse($conn, "drop table scott.hallo");
ociexecute($stmt);
echo $conn . " dropped table\n\n";
}
function insert_data($conn) {
function insert_data($conn)
{
$stmt = ociparse($conn, "insert into scott.hallo
values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . " inserted hallo\n\n";
}
function delete_data($conn) {
function delete_data($conn)
{
$stmt = ociparse($conn, "delete from scott.hallo");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . " deleted hallo\n\n";
}
function commit($conn) {
function commit($conn)
{
ocicommit($conn);
echo $conn . " committed\n\n";
}
function rollback($conn) {
function rollback($conn)
{
ocirollback($conn);
echo $conn . " rollback\n\n";
}
function select_data($conn) {
function select_data($conn)
{
$stmt = ociparse($conn, "select * from scott.hallo");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . "----selecting\n\n";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/outcontrol.xml, last change in rev 1.1 -->
<refentry id="function.ob-start">
<refnamediv>
@ -79,7 +79,8 @@
<![CDATA[
<?php
function callback($buffer) {
function callback($buffer)
{
// replace all the apples with oranges
return (str_replace("apples", "oranges", $buffer));
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<reference id="ref.overload">
<title>Object property and method call overloading</title>
<titleabbrev>Object overloading</titleabbrev>
@ -62,7 +62,8 @@ class OO {
var $elem = array('b' => 9, 'c' => 42);
// Callback method for getting a property
function __get($prop_name, &$prop_value) {
function __get($prop_name, &$prop_value)
{
if (isset($this->elem[$prop_name])) {
$prop_value = $this->elem[$prop_name];
return true;
@ -72,7 +73,8 @@ class OO {
}
// Callback method for setting a property
function __set($prop_name, $prop_value) {
function __set($prop_name, $prop_value)
{
$this->elem[$prop_name] = $prop_value;
return true;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/pcntl.xml, last change in rev 1.2 -->
<refentry id="function.pcntl-signal">
<refnamediv>
@ -50,7 +50,8 @@
declare(ticks = 1);
// signal handler function
function sig_handler($signo) {
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<reference id="ref.pcntl">
<title>Process Control Functions</title>
<titleabbrev>PCNTL</titleabbrev>
@ -99,7 +99,8 @@ while (1) {
}
function sig_handler($signo) {
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.47 -->
<refentry id="function.preg-replace-callback">
<refnamediv>
@ -34,7 +34,8 @@
$text.= "Last christmas was 12/24/2001\n";
// the callback function
function next_year($matches) {
function next_year($matches)
{
// as usual: $matches[0] is the complete match
// $matches[1] the match for the first subpattern
// enclosed in '(...)' and so on

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/sesam.xml, last change in rev 1.1 -->
<refentry id="function.sesam-diagnostic">
<refnamediv>
@ -80,7 +80,8 @@
// Function which prints a formatted error message,
// displaying a pointer to the syntax error in the
// SQL statement
function PrintReturncode($exec_str) {
function PrintReturncode($exec_str)
{
$err = Sesam_Diagnostic();
$colspan=4; // 4 cols for: sqlstate, errlin, errcol, rowcount
if ($err["errlin"] == -1)
@ -108,12 +109,14 @@ function PrintReturncode($exec_str) {
$i = "";
$line = substr ($errstmt, 0, strlen ($errstmt)-strlen($i)+1);
$errstmt = substr($i, 1);
for ($col=0; $col < $err["errcol"]; ++$col)
for ($col=0; $col < $err["errcol"]; ++$col) {
echo (substr($line, $col, 1) == "\t") ? "\t" : ".";
}
echo "<span class=\"spanred\">\\</span>\n";
echo "<span class=\"normal\">" . htmlspecialchars($line) . "</span>";
for ($col=0; $col < $err["errcol"]; ++$col)
for ($col=0; $col < $err["errcol"]; ++$col) {
echo (substr ($line, $col, 1) == "\t") ? "\t" : ".";
}
echo "<span class=\"spanred\">/</span>\n";
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/session.xml, last change in rev 1.23 -->
<refentry id="function.session-set-save-handler">
<refnamediv>
@ -65,7 +65,8 @@
<programlisting role="php">
<![CDATA[
<?php
function open($save_path, $session_name) {
function open($save_path, $session_name)
{
global $sess_save_path, $sess_session_name;
$sess_save_path = $save_path;
@ -73,11 +74,13 @@ function open($save_path, $session_name) {
return(true);
}
function close() {
function close()
{
return(true);
}
function read($id) {
function read($id)
{
global $sess_save_path, $sess_session_name;
$sess_file = "$sess_save_path/sess_$id";
@ -90,7 +93,8 @@ function read($id) {
}
function write($id, $sess_data) {
function write($id, $sess_data)
{
global $sess_save_path, $sess_session_name;
$sess_file = "$sess_save_path/sess_$id";
@ -102,7 +106,8 @@ function write($id, $sess_data) {
}
function destroy($id) {
function destroy($id)
{
global $sess_save_path, $sess_session_name;
$sess_file = "$sess_save_path/sess_$id";
@ -113,7 +118,8 @@ function destroy($id) {
* WARNING - You will need to implement some *
* sort of garbage collection routine here. *
*********************************************/
function gc($maxlifetime) {
function gc($maxlifetime)
{
return true;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.sqlite-create-aggregate">
<refnamediv>
<refname>sqlite_create_aggregate</refname>
@ -56,13 +56,15 @@ foreach ($data as $str) {
sqlite_query($dbhandle, "INSERT INTO strings VALUES ('$str')");
}
function max_len_step(&$context, $string) {
function max_len_step(&$context, $string)
{
if (strlen($string) > $context) {
$context = strlen($string);
}
}
function max_len_finalize(&$context) {
function max_len_finalize(&$context)
{
return $context;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<refentry id="function.sqlite-create-function">
<refnamediv>
<refname>sqlite_create_function</refname>
@ -43,7 +43,8 @@
<programlisting role="php">
<![CDATA[
<?php
function md5_and_reverse($string) {
function md5_and_reverse($string)
{
return strrev(md5($string));
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<refentry id="function.sqlite-udf-decode-binary">
<refnamediv>
<refname>sqlite_udf_decode_binary</refname>
@ -51,14 +51,16 @@ foreach ($data as $str) {
sqlite_query($db, "INSERT INTO strings VALUES ('$str')");
}
function max_len_step(&$context, $string) {
function max_len_step(&$context, $string)
{
$string = sqlite_udf_decode_binary($string);
if (strlen($string) > $context) {
$context = strlen($string);
}
}
function max_len_finalize(&$context) {
function max_len_finalize(&$context)
{
return $context;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.stream-filter-register">
<refnamediv>
<refname>stream_filter_register</refname>
@ -160,7 +160,8 @@
/* Define our filter class */
class strtoupper_filter extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data = strtoupper($bucket->data);
$consumed += $bucket->datalen;
@ -215,7 +216,8 @@ EASY AS 123
class string_filter extends php_user_filter {
var $mode;
function filter($in, $out, &$consumed, $closing) {
function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
if ($this->mode == 1) {
$bucket->data = strtoupper($bucket->data);
@ -229,7 +231,8 @@ class string_filter extends php_user_filter {
return PSFS_PASS_ON;
}
function oncreate() {
function oncreate()
{
if ($this->filtername == 'str.toupper') {
$this->mode = 1;
} elseif ($this->filtername == 'str.tolower') {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<refentry id="function.stream-wrapper-register">
<refnamediv>
<refname>stream_wrapper_register</refname>
@ -404,7 +404,8 @@ class VariableStream {
var $position;
var $varname;
function stream_open($path, $mode, $options, &$opened_path) {
function stream_open($path, $mode, $options, &$opened_path)
{
$url = parse_url($path);
$this->varname = $url["host"];
$this->position = 0;
@ -412,13 +413,15 @@ class VariableStream {
return true;
}
function stream_read($count) {
function stream_read($count)
{
$ret = substr($GLOBALS[$this->varname], $this->position, $count);
$this->position += strlen($ret);
return $ret;
}
function stream_write($data) {
function stream_write($data)
{
$left = substr($GLOBALS[$this->varname], 0, $this->position);
$right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
$GLOBALS[$this->varname] = $left . $data . $right;
@ -426,15 +429,18 @@ class VariableStream {
return strlen($data);
}
function stream_tell() {
function stream_tell()
{
return $this->position;
}
function stream_eof() {
function stream_eof()
{
return $this->position >= strlen($GLOBALS[$this->varname]);
}
function stream_seek($offset, $whence) {
function stream_seek($offset, $whence)
{
switch ($whence) {
case SEEK_SET:
if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.html-entity-decode">
<refnamediv>
@ -76,7 +76,8 @@ echo $b; // I'll "walk" the <b>dog</b> now
// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities($string) {
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/swf.xml, last change in rev 1.8 -->
<refentry id="function.swf-closefile">
<refnamediv>
@ -67,7 +67,8 @@ $data ?
// void swf_savedata(string data)
// Save the generated file a database
// for later retrieval
function swf_savedata($data) {
function swf_savedata($data)
{
global $DBHOST,
$DBUSER,
$DBPASS;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.sybase-set-message-handler">
<refnamediv>
<refname>sybase_set_message_handler</refname>
@ -32,7 +32,8 @@
<programlisting role="php">
<![CDATA[
<?php
function msg_handler($msgnumber, $severity, $state, $line, $text) {
function msg_handler($msgnumber, $severity, $state, $line, $text)
{
var_dump($msgnumber, $severity, $state, $line, $text);
}
@ -47,7 +48,8 @@
<![CDATA[
<?php
class Sybase {
function handler($msgnumber, $severity, $state, $line, $text) {
function handler($msgnumber, $severity, $state, $line, $text)
{
var_dump($msgnumber, $severity, $state, $line, $text);
}
}
@ -66,7 +68,8 @@
// Return FALSE from this function to indicate you can't handle
// this. The error is printed out as a warning, the way you're used
// to it if there is no handler installed.
function msg_handler($msgnumber, $severity, $state, $line, $text) {
function msg_handler($msgnumber, $severity, $state, $line, $text)
{
if (257 == $msgnumber) {
return false;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.http-build-query">
<refnamediv>
<refname>http_build_query</refname>
@ -115,7 +115,8 @@ class myClass {
var $foo;
var $baz;
function myClass() {
function myClass()
{
$this->foo = 'bar';
$this->baz = 'boom';
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.87 -->
<refentry id="function.is-callable">
<refnamediv>
@ -55,7 +55,8 @@
// Simple variable containing a function
//
function someFunction() {
function someFunction()
{
}
$functionVariable = 'someFunction';
@ -70,7 +71,8 @@ echo $callable_name, "\n"; // someFunction
class someClass {
function someMethod() {
function someMethod()
{
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.35 -->
<refentry id="function.is-scalar">
<refnamediv>
@ -30,7 +30,8 @@
programmers. -->
<![CDATA[
<?php
function show_var($var) {
function show_var($var)
{
if (is_scalar($var)) {
echo $var;
} else {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.14 $ -->
<!-- $Revision: 1.15 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
<refentry id="function.unserialize">
<refnamediv>
@ -50,7 +50,8 @@ $serialized_object='O:1:"a":1:{s:5:"value";s:3:"100";}';
// unserialize_callback_func directive available as of PHP 4.2.0
ini_set('unserialize_callback_func', 'mycallback'); // set your callback_function
function mycallback($classname) {
function mycallback($classname)
{
// just include a file containing your classdefinition
// you get $classname to figure out which classdefinition is required
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
<refentry id="function.unset">
<refnamediv>
@ -57,7 +57,8 @@ unset($foo1, $foo2, $foo3);
<programlisting role="php">
<![CDATA[
<?php
function destroy_foo() {
function destroy_foo()
{
global $foo;
unset($foo);
}
@ -88,7 +89,8 @@ bar
<programlisting role="php">
<![CDATA[
<?php
function foo(&$bar) {
function foo(&$bar)
{
unset($bar);
$bar = "blah";
}
@ -120,7 +122,8 @@ something
<programlisting role="php">
<![CDATA[
<?php
function foo() {
function foo()
{
static $a;
$a++;
echo "$a\n";
@ -153,7 +156,8 @@ foo();
<programlisting role="php">
<![CDATA[
<?php
function foo() {
function foo()
{
unset($GLOBALS['bar']);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/xml.xml, last change in rev 1.11 -->
<refentry id="function.xml-parse-into-struct">
<refnamediv>
@ -144,13 +144,15 @@ class AminoAcid {
var $code; // one letter code
var $type; // hydrophobic, charged or neutral
function AminoAcid ($aa) {
function AminoAcid ($aa)
{
foreach ($aa as $k=>$v)
$this->$k = $aa[$k];
}
}
function readDatabase($filename) {
function readDatabase($filename)
{
// read the XML database of aminoacids
$data = implode("", file($filename));
$parser = xml_parser_create();
@ -177,9 +179,11 @@ function readDatabase($filename) {
return $tdb;
}
function parseMol($mvalues) {
for ($i=0; $i < count($mvalues); $i++)
function parseMol($mvalues)
{
for ($i=0; $i < count($mvalues); $i++) {
$mol[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
}
return new AminoAcid($mol);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/xml.xml, last change in rev 1.2 -->
<refentry id="function.xml-set-object">
<refnamediv>
@ -25,7 +25,8 @@
class xml {
var $parser;
function xml() {
function xml()
{
$this->parser = xml_parser_create();
xml_set_object($this->parser, &$this);
@ -33,19 +34,23 @@ class xml {
xml_set_character_data_handler($this->parser, "cdata");
}
function parse($data) {
function parse($data)
{
xml_parse($this->parser, $data);
}
function tag_open($parser, $tag, $attributes) {
function tag_open($parser, $tag, $attributes)
{
var_dump($parser, $tag, $attributes);
}
function cdata($parser, $cdata) {
function cdata($parser, $cdata)
{
var_dump($parser, $cdata);
}
function tag_close($parser, $tag) {
function tag_close($parser, $tag)
{
var_dump($parser, $tag);
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<reference id="ref.xml">
<title>XML parser functions</title>
<titleabbrev>XML</titleabbrev>
@ -282,7 +282,8 @@ libexpat.a: $(OBJS)
$file = "data.xml";
$depth = array();
function startElement($parser, $name, $attrs) {
function startElement($parser, $name, $attrs)
{
global $depth;
for ($i = 0; $i < $depth[$parser]; $i++) {
echo " ";
@ -291,7 +292,8 @@ function startElement($parser, $name, $attrs) {
$depth[$parser]++;
}
function endElement($parser, $name) {
function endElement($parser, $name)
{
global $depth;
$depth[$parser]--;
}
@ -339,21 +341,24 @@ $map_array = array(
"LITERAL" => "TT"
);
function startElement($parser, $name, $attrs) {
function startElement($parser, $name, $attrs)
{
global $map_array;
if ($htmltag == $map_array[$name]) {
echo "<$htmltag>";
}
}
function endElement($parser, $name) {
function endElement($parser, $name)
{
global $map_array;
if ($htmltag == $map_array[$name]) {
echo "</$htmltag>";
}
}
function characterData($parser, $data) {
function characterData($parser, $data)
{
echo $data;
}
@ -403,7 +408,8 @@ xml_parser_free($xml_parser);
<?php
$file = "xmltest.xml";
function trustedFile($file) {
function trustedFile($file)
{
// only trust local files owned by ourselves
if (!eregi("^([a-z]+)://", $file)
&& fileowner($file) == getmyuid()) {
@ -412,7 +418,8 @@ function trustedFile($file) {
return false;
}
function startElement($parser, $name, $attribs) {
function startElement($parser, $name, $attribs)
{
echo "&lt;<font color=\"#0000cc\">$name</font>";
if (sizeof($attribs)) {
while (list($k, $v) = each($attribs)) {
@ -423,15 +430,18 @@ function startElement($parser, $name, $attribs) {
echo "&gt;";
}
function endElement($parser, $name) {
function endElement($parser, $name)
{
echo "&lt;/<font color=\"#0000cc\">$name</font>&gt;";
}
function characterData($parser, $data) {
function characterData($parser, $data)
{
echo "<b>$data</b>";
}
function PIHandler($parser, $target, $data) {
function PIHandler($parser, $target, $data)
{
switch (strtolower($target)) {
case "php":
global $parser_file;
@ -448,7 +458,8 @@ function PIHandler($parser, $target, $data) {
}
}
function defaultHandler($parser, $data) {
function defaultHandler($parser, $data)
{
if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
printf('<font color="#aa00aa">%s</font>',
htmlspecialchars($data));
@ -481,7 +492,8 @@ function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId,
return false;
}
function new_xml_parser($file) {
function new_xml_parser($file)
{
global $parser_file;
$xml_parser = xml_parser_create();

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.3 -->
<refentry id="function.xslt-create">
<refnamediv>
@ -22,7 +22,8 @@
<programlisting role="php">
<![CDATA[
<?php
function xml2html($xmldata, $xsl) {
function xml2html($xmldata, $xsl)
{
/* $xmldata -> your XML */
/* $xsl -> XSLT file */

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/yaz.xml, last change in rev 1.8 -->
<refentry id="function.yaz-scan">
<refnamediv>
@ -45,7 +45,8 @@
<programlisting role="php">
<![CDATA[
<?php
function scan_titles($id, $startterm) {
function scan_titles($id, $startterm)
{
yaz_scan($id, "rpn", "@attr 1=4 " . $startterm);
yaz_wait();
$errno = yaz_errno($id);