From 406be9eedc15611439e3abdb58c9d2f556968898 Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Tue, 6 Jan 2004 09:23:31 +0000 Subject: [PATCH] more CS git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@147957 c90b9560-bf6c-de11-be94-00142212c4b1 --- appendices/migration.xml | 6 +- chapters/tutorial.xml | 6 +- features/file-upload.xml | 20 +-- features/http-auth.xml | 12 +- language/control-structures.xml | 26 +-- language/functions.xml | 9 +- language/oop.xml | 165 +++++++----------- language/variables.xml | 26 +-- .../apache/functions/apache-get-version.xml | 4 +- reference/imap/functions/imap-utf8.xml | 6 +- .../mnogosearch/functions/udm-api-version.xml | 4 +- reference/mysql/functions/mysql-connect.xml | 10 +- reference/mysql/functions/mysql-tablename.xml | 7 +- .../functions/output-add-rewrite-var.xml | 6 +- reference/yaz/reference.xml | 4 +- security/index.xml | 16 +- 16 files changed, 144 insertions(+), 183 deletions(-) diff --git a/appendices/migration.xml b/appendices/migration.xml index 3138a5a5e1..3488673e9e 100644 --- a/appendices/migration.xml +++ b/appendices/migration.xml @@ -1,5 +1,5 @@ - + Migrating from PHP/FI 2 to PHP 3 @@ -292,7 +292,7 @@ while ((string)$key != "") { \n"); + echo("Could not open $file for reading
\n"); endif; ]]> @@ -301,7 +301,7 @@ endif; Migration from 2.0: return values, new code \n"); +$fp = @fopen($file, "r") or print("Could not open $file for reading
\n"); ]]>
diff --git a/chapters/tutorial.xml b/chapters/tutorial.xml index 119e907075..1a6b07c9ed 100644 --- a/chapters/tutorial.xml +++ b/chapters/tutorial.xml @@ -1,5 +1,5 @@ - + A simple tutorial @@ -373,10 +373,10 @@ if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) { A simple HTML form +
Your name: Your age: - +
]]>
diff --git a/features/file-upload.xml b/features/file-upload.xml index 8b1fe9a3c2..89ef6c4122 100644 --- a/features/file-upload.xml +++ b/features/file-upload.xml @@ -1,5 +1,5 @@ - + Handling file uploads @@ -40,10 +40,10 @@ File Upload Form - -Send this file: - +
+ + Send this file: +
]]>
@@ -361,11 +361,11 @@ print ""; Uploading multiple files - Send these files:
-
-
- +
+ Send these files:
+
+
+
]]>
diff --git a/features/http-auth.xml b/features/http-auth.xml index 44783272e3..098d23e966 100644 --- a/features/http-auth.xml +++ b/features/http-auth.xml @@ -1,5 +1,5 @@ - + HTTP authentication with PHP @@ -132,12 +132,12 @@ authenticate(); } else { - echo "

Welcome: {$_SERVER['PHP_AUTH_USER']}
"; + echo "

Welcome: {$_SERVER['PHP_AUTH_USER']}
"; echo "Old: {$_REQUEST['OldAuth']}"; - echo "

\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "

\n"; } ?> diff --git a/language/control-structures.xml b/language/control-structures.xml index e0a0ca7bd7..e749cf790d 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -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
\n"; + echo "Value: $value
\n"; } foreach ($arr as $value) { - echo "Value: $value
\n"; + echo "Value: $value
\n"; } ?> ]]> @@ -578,11 +578,11 @@ foreach ($arr as $value) { \n"; + echo "Key: $key; Value: $value
\n"; } foreach ($arr as $key => $value) { - echo "Key: $key; Value: $value
\n"; + echo "Key: $key; Value: $value
\n"; } ?> ]]> @@ -675,7 +675,7 @@ while (list (, $val) = each ($arr)) { if ($val == 'stop') { break; /* You could also write 'break 1;' here. */ } - echo "$val
\n"; + echo "$val
\n"; } /* Using the optional argument. */ @@ -684,10 +684,10 @@ $i = 0; while (++$i) { switch ($i) { case 5: - echo "At 5
\n"; + echo "At 5
\n"; break 1; /* Exit only the switch. */ case 10: - echo "At 10; quitting
\n"; + echo "At 10; quitting
\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
\n"; + echo "Outer
\n"; while (1) { - echo "  Middle
\n"; + echo "  Middle
\n"; while (1) { - echo "  Inner
\n"; + echo "  Inner
\n"; continue 3; } - echo "This never gets output.
\n"; + echo "This never gets output.
\n"; } - echo "Neither does this.
\n"; + echo "Neither does this.
\n"; } ?> ]]> diff --git a/language/functions.xml b/language/functions.xml index 7581f7bf88..6a3ab2fa66 100644 --- a/language/functions.xml +++ b/language/functions.xml @@ -1,5 +1,5 @@ - + Functions @@ -440,14 +440,13 @@ $newref =& returns_reference(); \n"; +function foo() { + echo "In foo()
\n"; } function bar($arg = '') { - echo "In bar(); argument was '$arg'.
\n"; + echo "In bar(); argument was '$arg'.
\n"; } // This is a wrapper function around echo diff --git a/language/oop.xml b/language/oop.xml index 2fcc751343..bd153a4df0 100644 --- a/language/oop.xml +++ b/language/oop.xml @@ -1,5 +1,5 @@ - + Classes and Objects @@ -14,21 +14,18 @@ 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 { todays_date = date("Y-m-d"); $this->name = $GLOBALS['firstname']; /* etc. . . */ @@ -257,12 +251,10 @@ $cart->$myvar = array("10" => 1); owner = $name; } } @@ -338,11 +330,9 @@ $ncart->add_item("10", 1); // (inherited functionality from cart) 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 add_item ($item, $num); } } @@ -403,19 +391,15 @@ $different_cart = new Constructor_Cart("20", 17); \n"; +class A { + function A() { + echo "I am the constructor of A.
\n"; } } -class B extends A -{ - function C() - { - echo "I am a regular function.
\n"; +class B extends A { + function C() { + echo "I am a regular function.
\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.<br>' in PHP 4. + 'I am the constructor of A.<br />' in PHP 4. @@ -448,13 +432,13 @@ class A { function A() { - echo "I am the constructor of A.
\n"; + echo "I am the constructor of A.
\n"; } function B() { - echo "I am a regular function named B in class A.
\n"; - echo "I am not a constructor in A.
\n"; + echo "I am a regular function named B in class A.
\n"; + echo "I am not a constructor in A.
\n"; } } @@ -462,7 +446,7 @@ class B extends A { function C() { - echo "I am a regular function.
\n"; + echo "I am a regular function.
\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.<br>'. + called, printing 'I am the constructor of A.<br />'. @@ -534,34 +518,30 @@ $b = new B; \n"; +class A { + function example() { + echo "I am the original function A::example().
\n"; } } -class B extends A -{ - function example() - { - echo "I am the redefined function B::example().
\n"; +class B extends A { + function example() { + echo "I am the redefined function B::example().
\n"; A::example(); } } // there is no object of class A. // this will print -// I am the original function A::example().
+// I am the original function A::example().
A::example(); // create an object of class B. $b = new B; // this will print -// I am the redefined function B::example().
-// I am the original function A::example().
+// I am the redefined function B::example().
+// I am the original function A::example().
$b->example(); ?> ]]> @@ -629,19 +609,15 @@ $b->example(); \n"; +class A { + function example() { + echo "I am A::example() and provide basic functionality.
\n"; } } -class B extends A -{ - function example() - { - echo "I am B::example() and provide additional functionality.
\n"; +class B extends A { + function example() { + echo "I am B::example() and provide additional functionality.
\n"; parent::example(); } } @@ -703,12 +679,10 @@ $b->example(); one; } } @@ -811,10 +785,8 @@ $b->example(); echoName(); } - function echoName() - { - echo "
",$this->name; + function echoName() { + echo "
", $this->name; } - function setName($name) - { + function setName($name) { $this->name = $name; } } @@ -932,37 +902,30 @@ set from outside */ 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 "
","class ",get_class($this),': ',$this->value; + function echoValue() { + echo "
","class ",get_class($this),': ',$this->value; } } -class B -{ - function B(&$a) - { +class B { + function B(&$a) { $this->a = &$a; } - function echoValue() - { - echo "
","class ",get_class($this),': ',$this->a->value; + function echoValue() { + echo "
","class ",get_class($this),': ',$this->a->value; } } @@ -981,18 +944,22 @@ $a->echoValue(); $a->b->echoValue(); // * $a->c->echoValue(); -/* -output: +?> +]]> +
+ + This example will output: + + + ]]> -
+
diff --git a/language/variables.xml b/language/variables.xml index 6891951c2b..24d057a29e 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -1,5 +1,5 @@ - + Variables @@ -807,10 +807,10 @@ echo "$a $hello"; A simple HTML form - Name:
- Email:
- +
+ Name:
+ Email:
+
]]>
@@ -912,17 +912,17 @@ if (isset($_POST['action']) && $_POST['action'] == 'submitted') { echo ''; } else { ?> -
- Name:
- Email:
- Beer:
+ + Name:
+ Email:
+ Beer:

- - +
+ +
+ ]]> diff --git a/reference/apache/functions/apache-get-version.xml b/reference/apache/functions/apache-get-version.xml index 866cba9089..639dc1a9ef 100644 --- a/reference/apache/functions/apache-get-version.xml +++ b/reference/apache/functions/apache-get-version.xml @@ -1,5 +1,5 @@ - + @@ -24,7 +24,7 @@ "; +echo "$version \n
"; ?> ]]>
diff --git a/reference/imap/functions/imap-utf8.xml b/reference/imap/functions/imap-utf8.xml index 2554851c04..16da473981 100644 --- a/reference/imap/functions/imap-utf8.xml +++ b/reference/imap/functions/imap-utf8.xml @@ -1,5 +1,5 @@ - + @@ -12,9 +12,7 @@ Description stringimap_utf8 - - stringmime_encoded_text - + stringmime_encoded_text Converts the given mime_encoded_text to diff --git a/reference/mnogosearch/functions/udm-api-version.xml b/reference/mnogosearch/functions/udm-api-version.xml index ca8611e3b1..53b232732f 100644 --- a/reference/mnogosearch/functions/udm-api-version.xml +++ b/reference/mnogosearch/functions/udm-api-version.xml @@ -1,5 +1,5 @@ - + @@ -30,7 +30,7 @@ = 30111) { - echo "Total number of urls in database: " . udm_get_doc_count($udm) . "
\n"; + echo "Total number of urls in database: " . udm_get_doc_count($udm) . "
\n"; } ?> ]]> diff --git a/reference/mysql/functions/mysql-connect.xml b/reference/mysql/functions/mysql-connect.xml index fe3452e8a8..d366fa6c74 100644 --- a/reference/mysql/functions/mysql-connect.xml +++ b/reference/mysql/functions/mysql-connect.xml @@ -1,5 +1,5 @@ - + @@ -10,12 +10,8 @@ Description resourcemysql_connect - string - server - - string - username - + stringserver + stringusername string password diff --git a/reference/mysql/functions/mysql-tablename.xml b/reference/mysql/functions/mysql-tablename.xml index 01cf5390d6..416afb45cb 100644 --- a/reference/mysql/functions/mysql-tablename.xml +++ b/reference/mysql/functions/mysql-tablename.xml @@ -1,5 +1,5 @@ - + @@ -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); ?> diff --git a/reference/outcontrol/functions/output-add-rewrite-var.xml b/reference/outcontrol/functions/output-add-rewrite-var.xml index ac69f1f6b8..517acfa2bc 100755 --- a/reference/outcontrol/functions/output-add-rewrite-var.xml +++ b/reference/outcontrol/functions/output-add-rewrite-var.xml @@ -1,5 +1,5 @@ - + output_add_rewrite_var @@ -34,7 +34,7 @@ output_add_rewrite_var('var', 'value'); echo 'link'; // a form -echo '
+echo '
'; @@ -49,7 +49,7 @@ print_r(ob_list_handlers()); link -
+
diff --git a/reference/yaz/reference.xml b/reference/yaz/reference.xml index b215263bd5..707a65b5b6 100644 --- a/reference/yaz/reference.xml +++ b/reference/yaz/reference.xml @@ -1,5 +1,5 @@ - + YAZ functions YAZ @@ -73,7 +73,7 @@ if (empty($term) || count($host) == 0) { local test - Library of Congress
diff --git a/security/index.xml b/security/index.xml index 5798835022..91aef14a0d 100644 --- a/security/index.xml +++ b/security/index.xml @@ -1,5 +1,5 @@ - + Security @@ -920,9 +920,9 @@ $query = sprintf("SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET %d Attacking Variables with a custom HTML page - - +
+ +
]]>
@@ -947,10 +947,10 @@ $query = sprintf("SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET %d Exploiting common debugging variables - - - +
+ + +
]]>