MemoryRefresh!

Control structures



Questions Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



* If Ternary operator
<?php echo 10 == $x ? 'YES' : 'NO'; * Switch A switch statement evaluates the initial expression ($a in this case) only once, and then compares it against the individual case values.
<?php switch($a) { case 1: // do one break; case 2: // do two break; default: // do zero } * While / Do These two types of loop are very similar. In a do ... while() loop, the check takes place at the end of each iteration of the loop - meaning that, even if the condition never evaluates to true, the contents of the loop will be executed at least once.
<?php // this ouput nothing $i = 10; while ($i < 10) { echo 1; $i++; } // this ouput 1 $i = 10; do { echo 1; $i++; } while ($i < 10); * For / Foreach * Break It takes an optional parameter, which allows you to exit from multiple nested loops
<?php for ($i=0; $i<=10; $i++) { for ($j=0; $j<=10; $j++) { if (($j + $i) % 5 == 0) { break 2; // Exist this loop and the next one } } } * Continue Like with break, you can provide it an integer parameter to specify the level of nesting to which the it applies
Questions

Related pages

Basic syntax !
Numeric type !
String type !
Boolean type !
Constants definition !
Control structures !
Reference !


0% 100%
 
 
0 pages 51 pages
1) In which of the following the contents of the loop is exectued at least once?





2) How you exit from two nested loops?





Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


* If Ternary operator
<?php echo 10 == $x ? 'YES' : 'NO'; * Switch A switch statement evaluates the initial expression ($a in this case) only once, and then compares it against the individual case values.
<?php switch($a) { case 1: // do one break; case 2: // do two break; default: // do zero } * While / Do These two types of loop are very similar. In a do ... while() loop, the check takes place at the end of each iteration of the loop - meaning that, even if the condition never evaluates to true, the contents of the loop will be executed at least once.
<?php // this ouput nothing $i = 10; while ($i < 10) { echo 1; $i++; } // this ouput 1 $i = 10; do { echo 1; $i++; } while ($i < 10); * For / Foreach * Break It takes an optional parameter, which allows you to exit from multiple nested loops
<?php for ($i=0; $i<=10; $i++) { for ($j=0; $j<=10; $j++) { if (($j + $i) % 5 == 0) { break 2; // Exist this loop and the next one } } } * Continue Like with break, you can provide it an integer parameter to specify the level of nesting to which the it applies



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com