git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@147957 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2004-01-06 09:23:31 +00:00
parent c4a4fa48cf
commit 406be9eedc
16 changed files with 144 additions and 183 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.24 $ -->
<!-- $Revision: 1.25 $ -->
<appendix id="migration">
<title>Migrating from PHP/FI 2 to PHP 3</title>
@ -292,7 +292,7 @@ while ((string)$key != "") {
<![CDATA[
$fp = fopen($file, "r");
if ($fp == -1);
echo("Could not open $file for reading<br>\n");
echo("Could not open $file for reading<br />\n");
endif;
]]>
</programlisting>
@ -301,7 +301,7 @@ endif;
<title>Migration from 2.0: return values, new code</title>
<programlisting role="php">
<![CDATA[
$fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n");
$fp = @fopen($file, "r") or print("Could not open $file for reading<br />\n");
]]>
</programlisting>
</example>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.25 $ -->
<!-- $Revision: 1.26 $ -->
<chapter id="tutorial">
<title>A simple tutorial</title>
@ -373,10 +373,10 @@ if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) {
<title>A simple HTML form</title>
<programlisting role="html">
<![CDATA[
<form action="action.php" method="POST">
<form action="action.php" method="post">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
<input type="submit" />
</form>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.66 $ -->
<!-- $Revision: 1.67 $ -->
<chapter id="features.file-upload">
<title>Handling file uploads</title>
@ -40,10 +40,10 @@
<title>File Upload Form</title>
<programlisting role="html">
<![CDATA[
<form enctype="multipart/form-data" action="_URL_" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
<form enctype="multipart/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
]]>
</programlisting>
@ -361,11 +361,11 @@ print "</pre>";
<title>Uploading multiple files</title>
<programlisting role="html">
<![CDATA[
<form action="file-upload.php" method="POST" enctype="multipart/form-data">
Send these files:<br>
<input name="userfile[]" type="file"><br>
<input name="userfile[]" type="file"><br>
<input type="submit" value="Send files">
<form action="file-upload.php" method="post" enctype="multipart/form-data">
Send these files:<br />
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Send files" />
</form>
]]>
</programlisting>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.36 $ -->
<!-- $Revision: 1.37 $ -->
<chapter id="features.http-auth">
<title>HTTP authentication with PHP</title>
@ -132,12 +132,12 @@
authenticate();
}
else {
echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br>";
echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br />";
echo "Old: {$_REQUEST['OldAuth']}";
echo "<form action='{$_SERVER['PHP_SELF']}' METHOD='POST'>\n";
echo "<input type='hidden' name='SeenBefore' value='1'>\n";
echo "<input type='hidden' name='OldAuth' value='{$_SERVER['PHP_AUTH_USER']}'>\n";
echo "<input type='submit' value='Re Authenticate'>\n";
echo "<form action='{$_SERVER['PHP_SELF']}' METHOD='post'>\n";
echo "<input type='hidden' name='SeenBefore' value='1' />\n";
echo "<input type='hidden' name='OldAuth' value='{$_SERVER['PHP_AUTH_USER']}' />\n";
echo "<input type='submit' value='Re Authenticate' />\n";
echo "</form></p>\n";
}
?>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.83 $ -->
<!-- $Revision: 1.84 $ -->
<chapter id="control-structures">
<title>Control Structures</title>
@ -561,11 +561,11 @@ foreach (array_expression as $key => $value) statement
$arr = array("one", "two", "three");
reset ($arr);
while (list(, $value) = each ($arr)) {
echo "Value: $value<br>\n";
echo "Value: $value<br />\n";
}
foreach ($arr as $value) {
echo "Value: $value<br>\n";
echo "Value: $value<br />\n";
}
?>
]]>
@ -578,11 +578,11 @@ foreach ($arr as $value) {
<?php
reset ($arr);
while (list($key, $value) = each ($arr)) {
echo "Key: $key; Value: $value<br>\n";
echo "Key: $key; Value: $value<br />\n";
}
foreach ($arr as $key => $value) {
echo "Key: $key; Value: $value<br>\n";
echo "Key: $key; Value: $value<br />\n";
}
?>
]]>
@ -675,7 +675,7 @@ while (list (, $val) = each ($arr)) {
if ($val == 'stop') {
break; /* You could also write 'break 1;' here. */
}
echo "$val<br>\n";
echo "$val<br />\n";
}
/* Using the optional argument. */
@ -684,10 +684,10 @@ $i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br>\n";
echo "At 5<br />\n";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br>\n";
echo "At 10; quitting<br />\n";
break 2; /* Exit the switch and the while. */
default:
break;
@ -734,16 +734,16 @@ while (list ($key, $value) = each ($arr)) {
$i = 0;
while ($i++ < 5) {
echo "Outer<br>\n";
echo "Outer<br />\n";
while (1) {
echo "&nbsp;&nbsp;Middle<br>\n";
echo "&nbsp;&nbsp;Middle<br />\n";
while (1) {
echo "&nbsp;&nbsp;Inner<br>\n";
echo "&nbsp;&nbsp;Inner<br />\n";
continue 3;
}
echo "This never gets output.<br>\n";
echo "This never gets output.<br />\n";
}
echo "Neither does this.<br>\n";
echo "Neither does this.<br />\n";
}
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.43 $ -->
<!-- $Revision: 1.44 $ -->
<chapter id="functions">
<title>Functions</title>
@ -440,14 +440,13 @@ $newref =& returns_reference();
<programlisting role="php">
<![CDATA[
<?php
function foo()
{
echo "In foo()<br>\n";
function foo() {
echo "In foo()<br />\n";
}
function bar($arg = '')
{
echo "In bar(); argument was '$arg'.<br>\n";
echo "In bar(); argument was '$arg'.<br />\n";
}
// This is a wrapper function around echo

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.48 $ -->
<!-- $Revision: 1.49 $ -->
<chapter id="language.oop">
<title>Classes and Objects</title>
@ -14,21 +14,18 @@
<programlisting role="php">
<![CDATA[
<?php
class Cart
{
class Cart {
var $items; // Items in our shopping cart
// Add $num articles of $artnr to the cart
function add_item ($artnr, $num)
{
function add_item($artnr, $num) {
$this->items[$artnr] += $num;
}
// Take $num articles of $artnr out of the cart
function remove_item ($artnr, $num)
{
function remove_item($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
return true;
@ -114,8 +111,7 @@ class test {
<programlisting role="php">
<![CDATA[
<?php
class Cart
{
class Cart {
/* None of these will work in PHP 4. */
var $todays_date = date("Y-m-d");
var $name = $firstname;
@ -125,15 +121,13 @@ class Cart
}
/* This is how it should be done. */
class Cart
{
class Cart {
var $todays_date;
var $name;
var $owner;
var $items = array("VCR", "TV");
function Cart()
{
function Cart() {
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
@ -257,12 +251,10 @@ $cart->$myvar = array("10" => 1);
<programlisting role="php">
<![CDATA[
<?php
class Named_Cart extends Cart
{
class Named_Cart extends Cart {
var $owner;
function set_owner ($name)
{
function set_owner ($name) {
$this->owner = $name;
}
}
@ -338,11 +330,9 @@ $ncart->add_item("10", 1); // (inherited functionality from cart)
<![CDATA[
<?php
// Works in PHP 3 and PHP 4.
class Auto_Cart extends Cart
{
function Auto_Cart()
{
$this->add_item ("10", 1);
class Auto_Cart extends Cart {
function Auto_Cart() {
$this->add_item("10", 1);
}
}
?>
@ -365,10 +355,8 @@ class Auto_Cart extends Cart
<![CDATA[
<?php
// Works in PHP 3 and PHP 4.
class Constructor_Cart extends Cart
{
function Constructor_Cart($item = "10", $num = 1)
{
class Constructor_Cart extends Cart {
function Constructor_Cart($item = "10", $num = 1) {
$this->add_item ($item, $num);
}
}
@ -403,19 +391,15 @@ $different_cart = new Constructor_Cart("20", 17);
<programlisting role="php">
<![CDATA[
<?php
class A
{
function A()
{
echo "I am the constructor of A.<br>\n";
class A {
function A() {
echo "I am the constructor of A.<br />\n";
}
}
class B extends A
{
function C()
{
echo "I am a regular function.<br>\n";
class B extends A {
function C() {
echo "I am a regular function.<br />\n";
}
}
@ -437,7 +421,7 @@ $b = new B;
This is fixed in PHP 4 by introducing another rule: If a class
has no constructor, the constructor of the base class is being
called, if it exists. The above example would have printed
'I am the constructor of A.&lt;br&gt;' in PHP 4.
'I am the constructor of A.&lt;br /&gt;' in PHP 4.
</para>
<informalexample>
@ -448,13 +432,13 @@ class A
{
function A()
{
echo "I am the constructor of A.<br>\n";
echo "I am the constructor of A.<br />\n";
}
function B()
{
echo "I am a regular function named B in class A.<br>\n";
echo "I am not a constructor in A.<br>\n";
echo "I am a regular function named B in class A.<br />\n";
echo "I am not a constructor in A.<br />\n";
}
}
@ -462,7 +446,7 @@ class B extends A
{
function C()
{
echo "I am a regular function.<br>\n";
echo "I am a regular function.<br />\n";
}
}
@ -486,7 +470,7 @@ $b = new B;
is a function of the same name as the class it is being defined
in.'. Thus in PHP 4, the class B would have no constructor function
of its own and the constructor of the base class would have been
called, printing 'I am the constructor of A.&lt;br&gt;'.
called, printing 'I am the constructor of A.&lt;br /&gt;'.
</para>
<caution>
@ -534,34 +518,30 @@ $b = new B;
<programlisting role="php">
<![CDATA[
<?php
class A
{
function example()
{
echo "I am the original function A::example().<br>\n";
class A {
function example() {
echo "I am the original function A::example().<br />\n";
}
}
class B extends A
{
function example()
{
echo "I am the redefined function B::example().<br>\n";
class B extends A {
function example() {
echo "I am the redefined function B::example().<br />\n";
A::example();
}
}
// there is no object of class A.
// this will print
// I am the original function A::example().<br>
// I am the original function A::example().<br />
A::example();
// create an object of class B.
$b = new B;
// this will print
// I am the redefined function B::example().<br>
// I am the original function A::example().<br>
// I am the redefined function B::example().<br />
// I am the original function A::example().<br />
$b->example();
?>
]]>
@ -629,19 +609,15 @@ $b->example();
<programlisting role="php">
<![CDATA[
<?php
class A
{
function example()
{
echo "I am A::example() and provide basic functionality.<br>\n";
class A {
function example() {
echo "I am A::example() and provide basic functionality.<br />\n";
}
}
class B extends A
{
function example()
{
echo "I am B::example() and provide additional functionality.<br>\n";
class B extends A {
function example() {
echo "I am B::example() and provide additional functionality.<br />\n";
parent::example();
}
}
@ -703,12 +679,10 @@ $b->example();
<?php
// classa.inc:
class A
{
class A {
var $one = 1;
function show_one()
{
function show_one() {
echo $this->one;
}
}
@ -811,10 +785,8 @@ $b->example();
<programlisting role="php">
<![CDATA[
<?php
class Foo
{
function Foo($name)
{
class Foo {
function Foo($name) {
// create a reference inside the global array $globalref
global $globalref;
$globalref[] = &$this;
@ -824,13 +796,11 @@ class Foo
$this->echoName();
}
function echoName()
{
echo "<br>",$this->name;
function echoName() {
echo "<br />", $this->name;
}
function setName($name)
{
function setName($name) {
$this->name = $name;
}
}
@ -932,37 +902,30 @@ set from outside */
<programlisting role="php">
<![CDATA[
<?php
class A
{
function A($i)
{
class A {
function A($i) {
$this->value = $i;
// try to figure out why we do not need a reference here
$this->b = new B($this);
}
function createRef()
{
function createRef() {
$this->c = new B($this);
}
function echoValue()
{
echo "<br>","class ",get_class($this),': ',$this->value;
function echoValue() {
echo "<br />","class ",get_class($this),': ',$this->value;
}
}
class B
{
function B(&$a)
{
class B {
function B(&$a) {
$this->a = &$a;
}
function echoValue()
{
echo "<br>","class ",get_class($this),': ',$this->a->value;
function echoValue() {
echo "<br />","class ",get_class($this),': ',$this->a->value;
}
}
@ -981,18 +944,22 @@ $a->echoValue();
$a->b->echoValue(); // *
$a->c->echoValue();
/*
output:
?>
]]>
</programlisting>
<para>
This example will output:
</para>
<screen>
<![CDATA[
class A: 10
class B: 10
class B: 10
class A: 11
class B: 11
class B: 11
*/
?>
]]>
</programlisting>
</screen>
</informalexample>
</para>
</sect1>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.73 $ -->
<!-- $Revision: 1.74 $ -->
<chapter id="language.variables">
<title>Variables</title>
@ -807,10 +807,10 @@ echo "$a $hello";
<title>A simple HTML form</title>
<programlisting role="html">
<![CDATA[
<form action="foo.php" method="POST">
Name: <input type="text" name="username"><br>
Email: <input type="text" name="email"><br>
<input type="submit" name="submit" value="Submit me!">
<form action="foo.php" method="post">
Name: <input type="text" name="username" /><br />
Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Submit me!" />
</form>
]]>
</programlisting>
@ -912,17 +912,17 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
echo '</pre>';
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Name: <input type="text" name="personal[name]"><br>
Email: <input type="text" name="personal[email]"><br>
Beer: <br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Name: <input type="text" name="personal[name]" /><br />
Email: <input type="text" name="personal[email]" /><br />
Beer: <br />
<select multiple name="beer[]">
<option value="warthog">Warthog</option>
<option value="guinness">Guinness</option>
<option value="stuttgarter">Stuttgarter Schwabenbräu</option>
</select><br>
<input type="hidden" name="action" value="submitted">
<input type="submit" name="submit" value="submit me!">
</select><br />
<input type="hidden" name="action" value="submitted" />
<input type="submit" name="submit" value="submit me!" />
</form>
<?php
}
@ -948,7 +948,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
<informalexample>
<programlisting role="html">
<![CDATA[
<input type="image" src="image.gif" name="sub">
<input type="image" src="image.gif" name="sub" />
]]>
</programlisting>
</informalexample>

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.apache-get-version">
<refnamediv>
@ -24,7 +24,7 @@
<![CDATA[
<?php
$version = apache_get_version();
echo "$version \n <br \>";
echo "$version \n <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/imap.xml, last change in rev 1.7 -->
<refentry id="function.imap-utf8">
<refnamediv>
@ -12,9 +12,7 @@
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>imap_utf8</methodname>
<methodparam>
<type>string</type><parameter>mime_encoded_text</parameter>
</methodparam>
<methodparam><type>string</type><parameter>mime_encoded_text</parameter></methodparam>
</methodsynopsis>
<para>
Converts the given <parameter>mime_encoded_text</parameter> to

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/mnogosearch.xml, last change in rev 1.18 -->
<refentry id="function.udm-api-version">
<refnamediv>
@ -30,7 +30,7 @@
<![CDATA[
<?php
if (udm_api_version() >= 30111) {
echo "Total number of urls in database: " . udm_get_doc_count($udm) . "<br \>\n";
echo "Total number of urls in database: " . udm_get_doc_count($udm) . "<br />\n";
}
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- $Revision: 1.11 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-connect">
<refnamediv>
@ -10,12 +10,8 @@
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>mysql_connect</methodname>
<methodparam choice="opt"><type>string</type><parameter>
server
</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
username
</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>
password
</parameter></methodparam>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-tablename">
<refnamediv>
@ -30,8 +30,9 @@
mysql_connect("localhost", "mysql_user", "mysql_password");
$result = mysql_list_tables("mydb");
for ($i = 0; $i < mysql_num_rows($result); $i++)
printf("Table: %s\n", mysql_tablename($result, $i));
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo "Table: ", mysql_tablename($result, $i), "\n";
}
mysql_free_result($result);
?>

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry id="function.output-add-rewrite-var">
<refnamediv>
<refname>output_add_rewrite_var</refname>
@ -34,7 +34,7 @@ output_add_rewrite_var('var', 'value');
echo '<a href="file.php">link</a>';
// a form
echo '<form action="script.php" method="POST">
echo '<form action="script.php" method="post">
<input type="text" name="var2" />
</form>';
@ -49,7 +49,7 @@ print_r(ob_list_handlers());
<![CDATA[
<a href="file.php?var=value">link</a>
<form action="script.php" method="POST">
<form action="script.php" method="post">
<input type="hidden" name="var" value="value" />
<input type="text" name="var2" />
</form>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.14 $ -->
<!-- $Revision: 1.15 $ -->
<reference id="ref.yaz">
<title>YAZ functions</title>
<titleabbrev>YAZ</titleabbrev>
@ -73,7 +73,7 @@ if (empty($term) || count($host) == 0) {
<input type="checkbox"
name="host[]" value="localhost:9999/Default" />
local test
<input type="checkbox" checked="1"
<input type="checkbox" checked="checked"
name="host[]" value="z3950.loc.gov:7090/voyager" />
Library of Congress
<br />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.65 $ -->
<!-- $Revision: 1.66 $ -->
<chapter id="security.index">
<title>Security</title>
@ -920,9 +920,9 @@ $query = sprintf("SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET %d
<title>Attacking Variables with a custom HTML page</title>
<programlisting role="php">
<![CDATA[
<form method="POST" action="attacktarget?username=badfoo&password=badfoo">
<input type="hidden" name="username" value="badfoo">
<input type="hidden" name="password" value="badfoo">
<form method="post" action="attacktarget?username=badfoo&password=badfoo">
<input type="hidden" name="username" value="badfoo" />
<input type="hidden" name="password" value="badfoo" />
</form>
]]>
</programlisting>
@ -947,10 +947,10 @@ $query = sprintf("SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET %d
<title>Exploiting common debugging variables</title>
<programlisting role="php">
<![CDATA[
<form method="POST" action="attacktarget?errors=Y&amp;showerrors=1&amp;debug=1">
<input type="hidden" name="errors" value="Y">
<input type="hidden" name="showerrors" value="1">
<input type="hidden" name="debug" value="1">
<form method="post" action="attacktarget?errors=Y&amp;showerrors=1&amp;debug=1">
<input type="hidden" name="errors" value="Y" />
<input type="hidden" name="showerrors" value="1" />
<input type="hidden" name="debug" value="1" />
</form>
]]>
</programlisting>