mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Cosmetic changes: coding styles, paragraphs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@160136 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
88f5107e6e
commit
f56f8c844f
1 changed files with 19 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.48 $ -->
|
||||
<!-- $Revision: 1.49 $ -->
|
||||
<chapter id="language.functions">
|
||||
<title>Functions</title>
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo ($arg_1, $arg_2, /* ..., */ $arg_n)
|
||||
function foo($arg_1, $arg_2, /* ..., */ $arg_n)
|
||||
{
|
||||
echo "Example function.\n";
|
||||
return $retval;
|
||||
|
@ -66,7 +66,7 @@ $makefoo = true;
|
|||
bar();
|
||||
|
||||
if ($makefoo) {
|
||||
function foo ()
|
||||
function foo()
|
||||
{
|
||||
echo "I don't exist until program execution reaches me.\n";
|
||||
}
|
||||
|
@ -228,12 +228,12 @@ echo $str; // outputs 'This is a string, and something extra.'
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function makecoffee ($type = "cappuccino")
|
||||
function makecoffee($type = "cappuccino")
|
||||
{
|
||||
return "Making a cup of $type.\n";
|
||||
}
|
||||
echo makecoffee ();
|
||||
echo makecoffee ("espresso");
|
||||
echo makecoffee();
|
||||
echo makecoffee("espresso");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -250,20 +250,22 @@ Making a cup of espresso.
|
|||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Also PHP allows you to use arrays and special type NULL as
|
||||
default values, for example:
|
||||
Also PHP allows you to use arrays and special type NULL as
|
||||
default values, for example:
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Using non-scalar types as default values</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function makecoffee ($types = array("cappuccino"), $coffeeMaker = NULL)
|
||||
function makecoffee($types = array("cappuccino"), $coffeeMaker = NULL)
|
||||
{
|
||||
$device = is_null($coffeeMaker) ? "hands" : $coffeeMaker;
|
||||
return "Making a cup of ".join(", ", $types)." with $device.\n";
|
||||
}
|
||||
echo makecoffee ();
|
||||
echo makecoffee (array("cappuccino", "lavazza"), "teapot");
|
||||
echo makecoffee();
|
||||
echo makecoffee(array("cappuccino", "lavazza"), "teapot");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -285,12 +287,12 @@ echo makecoffee (array("cappuccino", "lavazza"), "teapot");
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function makeyogurt ($type = "acidophilus", $flavour)
|
||||
function makeyogurt($type = "acidophilus", $flavour)
|
||||
{
|
||||
return "Making a bowl of $type $flavour.\n";
|
||||
}
|
||||
|
||||
echo makeyogurt ("raspberry"); // won't work as expected
|
||||
echo makeyogurt("raspberry"); // won't work as expected
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -316,12 +318,12 @@ Making a bowl of raspberry .
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function makeyogurt ($flavour, $type = "acidophilus")
|
||||
function makeyogurt($flavour, $type = "acidophilus")
|
||||
{
|
||||
return "Making a bowl of $type $flavour.\n";
|
||||
}
|
||||
|
||||
echo makeyogurt ("raspberry"); // works as expected
|
||||
echo makeyogurt("raspberry"); // works as expected
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -376,11 +378,11 @@ Making a bowl of acidophilus raspberry.
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function square ($num)
|
||||
function square($num)
|
||||
{
|
||||
return $num * $num;
|
||||
}
|
||||
echo square (4); // outputs '16'.
|
||||
echo square(4); // outputs '16'.
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue