From f2e6bd1c0cd4895b4c0cd41c3a4c1fb5f30026e4 Mon Sep 17 00:00:00 2001 From: Friedhelm Betz Date: Sat, 17 Jan 2004 20:22:45 +0000 Subject: [PATCH] cs: indenting, use echo for output git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@149066 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/control-structures.xml | 185 ++++++++++++++++---------------- 1 file changed, 93 insertions(+), 92 deletions(-) diff --git a/language/control-structures.xml b/language/control-structures.xml index e749cf790d..b099c8eb39 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -49,7 +49,7 @@ if (expr) $b) - print "a is bigger than b"; + echo "a is bigger than b"; ?> ]]> @@ -69,7 +69,7 @@ if ($a > $b) $b) { - print "a is bigger than b"; + echo "a is bigger than b"; $b = $a; } ?> @@ -103,9 +103,9 @@ if ($a > $b) { $b) { - print "a is bigger than b"; + echo "a is bigger than b"; } else { - print "a is NOT bigger than b"; + echo "a is NOT bigger than b"; } ?> ]]> @@ -142,11 +142,11 @@ if ($a > $b) { $b) { - print "a is bigger than b"; + echo "a is bigger than b"; } elseif ($a == $b) { - print "a is equal to b"; + echo "a is equal to b"; } else { - print "a is smaller than b"; + echo "a is smaller than b"; } ?> ]]> @@ -211,13 +211,13 @@ A is equal to 5 ]]> @@ -282,7 +282,7 @@ while (expr): statement ... endwhile; $i = 1; while ($i <= 10) { - print $i++; /* the printed value would be + echo $i++; /* the printed value would be $i before the increment (post-increment) */ } @@ -291,7 +291,7 @@ while ($i <= 10) { $i = 1; while ($i <= 10): - print $i; + echo $i; $i++; endwhile; ?> @@ -325,7 +325,7 @@ endwhile; 0); ?> ]]> @@ -342,7 +342,7 @@ do { Advanced C users may be familiar with a different usage of the do..while loop, to allow stopping execution in the middle of code blocks, by encapsulating them with - do..while(0), and using the do..while (0), and using the break statement. The following code fragment demonstrates this: @@ -351,18 +351,18 @@ do { ]]> @@ -426,7 +426,7 @@ for (expr1; expr2; expr3) statement /* example 1 */ for ($i = 1; $i <= 10; $i++) { - print $i; + echo $i; } /* example 2 */ @@ -435,23 +435,23 @@ for ($i = 1; ; $i++) { if ($i > 10) { break; } - print $i; + echo $i; } /* example 3 */ $i = 1; -for (;;) { +for (; ; ) { if ($i > 10) { break; } - print $i; + echo $i; $i++; } /* example 4 */ -for ($i = 1; $i <= 10; print $i, $i++); +for ($i = 1; $i <= 10; echo $i, $i++); ?> ]]> @@ -576,7 +576,8 @@ foreach ($arr as $value) { \n"; } @@ -597,26 +598,26 @@ foreach ($arr as $key => $value) { $v.\n"; + echo "\$a[$i] => $v.\n"; $i++; } /* foreach example 3: key and value */ -$a = array ( +$a = array( "one" => 1, "two" => 2, "three" => 3, @@ -624,7 +625,7 @@ $a = array ( ); foreach ($a as $k => $v) { - print "\$a[$k] => $v.\n"; + echo "\$a[$k] => $v.\n"; } /* foreach example 4: multi-dimensional arrays */ @@ -636,14 +637,14 @@ $a[1][1] = "z"; foreach ($a as $v1) { foreach ($v1 as $v2) { - print "$v2\n"; + echo "$v2\n"; } } /* foreach example 5: dynamic arrays */ foreach (array(1, 2, 3, 4, 5) as $v) { - print "$v\n"; + echo "$v\n"; } ?> ]]> @@ -670,7 +671,7 @@ foreach (array(1, 2, 3, 4, 5) as $v) { The following two examples are two different ways to write the - same thing, one using a series of if - statements, and the other using the switch - statement: + same thing, one using a series of if and + elseif statements, and the other using the + switch statement: ]]> @@ -866,12 +867,12 @@ switch ($i) { ]]> @@ -879,9 +880,9 @@ switch ($i) { - Here, if $i is equal to 0, PHP would execute all of the print + Here, if $i is equal to 0, PHP would execute all of the echo statements! If $i is equal to 1, PHP would execute the last two - print statements. You would get the expected behavior ('i equals 2' + echo statements. You would get the expected behavior ('i equals 2' would be displayed) only if $i is equal to 2. Thus, it is important not to forget break statements (even though you may want to avoid supplying them on purpose under @@ -903,13 +904,13 @@ switch ($i) { ]]> @@ -925,17 +926,17 @@ switch ($i) { ]]> @@ -958,17 +959,17 @@ switch ($i) { ]]> @@ -1054,7 +1055,7 @@ declare(ticks=1); ;"; + echo similar_text(md5($x), md5($x*$x)), "
;"; } } // Display the data stored in the profiler -print_r (profile (TRUE)); +print_r(profile (TRUE)); ?> ]]>