mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Eliminate all <link> stuff from CDATA sections, and moved DEV comments
out of example code. The manual pages with these examples were a huge mess... git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@66335 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
f0c4b333bf
commit
f30786d728
1 changed files with 56 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.69 $ -->
|
||||
<!-- $Revision: 1.70 $ -->
|
||||
<chapter id="language.types">
|
||||
<title>Types</title>
|
||||
|
||||
|
@ -172,12 +172,13 @@ $foo = True; // assign the value TRUE to $foo
|
|||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
if ($action == "show_version") { // == is an <link linkend="language.operators">operator</link> which returns a <type>boolean</type>
|
||||
// == is an operator which returns a boolean
|
||||
if ($action == "show_version") {
|
||||
echo "The version is 1.23";
|
||||
}
|
||||
|
||||
// this is not necessary:
|
||||
if ($show_separators == true) {
|
||||
if ($show_separators == TRUE) {
|
||||
echo "<hr>\n";
|
||||
}
|
||||
|
||||
|
@ -833,20 +834,22 @@ echo "He drunk some ${beer}s"; // works
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$fruits = array( 'strawberry' => 'red' , 'banana' => 'yellow' );
|
||||
echo "A banana is $fruits[banana]."; // note that this works differently
|
||||
outside string-quotes. See <link
|
||||
linkend="language.types.array.foo-bar"><literal>$foo[bar]</literal> outside strings</link>
|
||||
echo "This square is $square->width meters broad.";
|
||||
echo "This square is $square->width00 centimeters broad."; // won't work,
|
||||
// for a solution, see the <link linkend="language.types.string.parsing.complex">complex syntax</link>.
|
||||
|
||||
// note that this works differently outside string-quotes.
|
||||
echo "A banana is $fruits[banana].";
|
||||
|
||||
echo "This square is $square->width meters broad.";
|
||||
|
||||
// Won't work. For a solution, see the complex syntax.
|
||||
echo "This square is $square->width00 centimeters broad.";
|
||||
|
||||
]]>
|
||||
<!-- XXX this won't work:
|
||||
echo "This square is $square->{width}00 centimeters broad.";
|
||||
// XXX: php developers: it would be consequent to make this work.
|
||||
// XXX: like the $obj->{expr} syntax outside a string works,
|
||||
// XXX: analogously to the ${expr} syntax for variable var's.
|
||||
-->
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<simpara>
|
||||
|
@ -876,19 +879,21 @@ echo "This is { $great}"; // won't work, outputs: This is { fantastic}
|
|||
echo "This is {$great}"; // works, outputs: This is fantastic
|
||||
echo "This square is {$square->width}00 centimeters broad.";
|
||||
echo "This works: {$arr[4][3]}";
|
||||
echo "This is wrong: {$arr[foo][3]}"; // for the same reason
|
||||
// as <link linkend="language.types.array.foo-bar">$foo[bar]</link
|
||||
> is wrong outside a string.
|
||||
|
||||
// This is wrong for the same reason
|
||||
// as $foo[bar] is wrong outside a string.
|
||||
echo "This is wrong: {$arr[foo][3]}";
|
||||
|
||||
echo "You should do it this way: {$arr['foo'][3]}";
|
||||
echo "You can even write {$obj->values[3]->name}";
|
||||
echo "This is the value of the var named $name: {${$name}}";
|
||||
<!-- <xxx> maybe it's better to leave this out??
|
||||
]]>
|
||||
<!-- maybe it's better to leave this out??
|
||||
// this works, but i disencourage its use, since this is NOT
|
||||
// involving functions, rather than mere variables, arrays and objects.
|
||||
$beer = 'Heineken';
|
||||
echo "I'd like to have another {${ strrev('reeb') }}, hips";
|
||||
</xxx> -->
|
||||
]]>
|
||||
-->
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</sect4>
|
||||
|
@ -911,10 +916,10 @@ echo "I'd like to have another {${ strrev('reeb') }}, hips";
|
|||
<example>
|
||||
<title>Some string examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<!-- TODO: either move these examples to a example section,
|
||||
as with arrays, or distribute them under the applicable
|
||||
sections. -->
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* Assigning a string. */
|
||||
$str = "This is a string";
|
||||
|
@ -1365,6 +1370,9 @@ $switching = array( 10 // key = 0
|
|||
, 0 => 12 // the value 10 will be overwritten by 12
|
||||
);
|
||||
|
||||
// empty array
|
||||
$empty = array();
|
||||
]]>
|
||||
<!-- TODO example of
|
||||
- mixed keys
|
||||
- overwriting keys
|
||||
|
@ -1372,10 +1380,6 @@ $switching = array( 10 // key = 0
|
|||
- using vars/functions as key/values
|
||||
- mixed skipping
|
||||
-->
|
||||
|
||||
// empty array
|
||||
$empty = array();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
|
@ -1412,14 +1416,15 @@ Do you like yellow?
|
|||
<example id="language.types.array.examples.changeloop">
|
||||
<title>Collection</title>
|
||||
<programlisting role="php">
|
||||
<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color ) {
|
||||
<![CDATA[
|
||||
foreach ($colors as $key => $color) {
|
||||
// won't work:
|
||||
//$color = <link linkend="function.strtoupper">strtoupper</link>($color);
|
||||
//$color = strtoupper($color);
|
||||
|
||||
//works:
|
||||
$colors[$key] = <link linkend="function.strtoupper">strtoupper</link>($color);
|
||||
$colors[$key] = strtoupper($color);
|
||||
}
|
||||
<link linkend="function.print-r">print_r</link>($colors);
|
||||
print_r($colors);
|
||||
|
||||
/* output:
|
||||
Array
|
||||
|
@ -1430,6 +1435,7 @@ Array
|
|||
[3] => YELLOW
|
||||
)
|
||||
*/
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1438,8 +1444,9 @@ Array
|
|||
<example>
|
||||
<title>One-based index</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$firstquarter = array(1 => 'January', 'February', 'March');
|
||||
<link linkend="function.print-r">print_r</link>($firstquarter);
|
||||
print_r($firstquarter);
|
||||
|
||||
/* output:
|
||||
Array
|
||||
|
@ -1448,20 +1455,23 @@ Array
|
|||
[2] => 'February'
|
||||
[3] => 'March'
|
||||
)
|
||||
*/
|
||||
*/
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<example>
|
||||
<title>Filling real array</title>
|
||||
<programlisting role="php">
|
||||
// fill an array with all items from a <link linkend="ref.dir">directory</link>
|
||||
$handle = <link linkend="function.opendir">opendir</link>('.');
|
||||
while ($file = <link linkend="function.readdir">readdir</link>($handle))
|
||||
<![CDATA[
|
||||
// fill an array with all items from a directory
|
||||
$handle = opendir('.');
|
||||
while ($file = readdir($handle))
|
||||
{
|
||||
$files[] = $file;
|
||||
}
|
||||
<link linkend="function.closedir">closedir</link>($handle);
|
||||
closedir($handle);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -1472,8 +1482,10 @@ while ($file = <link linkend="function.readdir">readdir</link>($handle))
|
|||
<example>
|
||||
<title>Sorting array</title>
|
||||
<programlisting role="php">
|
||||
<link linkend="function.sort">sort</link>($files);
|
||||
<link linkend="function.print-r">print_r</link>($files);
|
||||
<![CDATA[
|
||||
sort($files);
|
||||
print_r($files);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -1484,23 +1496,24 @@ while ($file = <link linkend="function.readdir">readdir</link>($handle))
|
|||
<example>
|
||||
<title>Recursive and multi-dimensional arrays</title>
|
||||
<programlisting role="php">
|
||||
$fruits = array ( "fruits" => array ( "a" => "orange"
|
||||
, "b" => "banana"
|
||||
, "c" => "apple"
|
||||
<![CDATA[
|
||||
$fruits = array ( "fruits" => array ( "a" => "orange"
|
||||
, "b" => "banana"
|
||||
, "c" => "apple"
|
||||
)
|
||||
, "numbers" => array ( 1
|
||||
, "numbers" => array ( 1
|
||||
, 2
|
||||
, 3
|
||||
, 4
|
||||
, 5
|
||||
, 6
|
||||
)
|
||||
, "holes" => array ( "first"
|
||||
, 5 => "second"
|
||||
, "holes" => array ( "first"
|
||||
, 5 => "second"
|
||||
, "third"
|
||||
)
|
||||
);
|
||||
|
||||
]]>
|
||||
<!-- quite duplicate...
|
||||
$a = array(
|
||||
"apple" => array(
|
||||
|
@ -1720,7 +1733,8 @@ echo $a["apple"]["taste"]; # will output "sweet"
|
|||
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
<![CDATA[
|
||||
<?php
|
||||
class foo
|
||||
{
|
||||
function do_foo()
|
||||
|
@ -1732,6 +1746,7 @@ class foo
|
|||
$bar = new foo;
|
||||
$bar->do_foo();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue