Tutorial for Do.. While loop

What is Do….While Loops?

The (do-while loop) is a version of the while loop in which the state is assessed at the end of each loop iteration. A (while loop) runs a block of code once and then evaluates the condition; if the condition is true, the expression is repeated as long as the condition is true.

Syntax:-


do {
  code to be executed;
} while (condition is true);
PHP Loop and  Control Structures

Example:-

Output:-

Tagged : / / / / / / / / / /

What is the use of break and continue?

Break Statement

Break Statement – This statement is used to “jumps out” of a loop. The break statement breaks the loop and continues executing the code after the loop (if any).

Continue Statement

Continue Statement – This statement is used to “jumps over” one iteration in the loop. The continue statement breaks one iteration (in the loop) if a specified condition occurs and continues with the next iteration in the loop.

Escape Sequences

Character ConstantMeaning
\bBackspace
\fForm feed
\nMove to new line
\rCarriage return (Enter)
\tHorizontal Tab
\vVertical Tab
\\Print back slash
\?Print question mark
\‟Print single quote
\”Print double quote
\0Null character
Tagged : / / /

Tutorial for while loop

What is while Loop?

As long as the (while) statement’s condition evaluates to true, the (while) assertion cycles around a block of code. They’re used to run a section of code repeatedly until the set condition is met. The while loop keeps repeating an action until an associated condition returns false.

PHP while statement - w3resource

Syntex:-

while (condition is true) {
  code to be executed;
}
PHP Loop and  Control Structures

Example1:-

Output:-

Example2:-

Output:-

Tagged : / / / / /

Tutorials for PHP Loops

What is Loop?

A loop is a repetition control structure. it causes a single statement or  block to be executed repeatedly What is a loop? - ppt download

A loop is an Iterative Control Structure that requires the same number of codes to be executed several times until a specific condition is met. When writing code, you may want a specific block of code to run a certain number of times. As a result, rather than applying nearly similar code lines to a script, we can employ loops.

What are the Different types of Loops?

PHP 7 Fundamental Tutorial for Beginners - PHP Loop - DevOpsSchool.com

Loops are used repeatedly to run the same piece of code as long as a given condition is met. A loop’s basic premise is to simplify recurring procedures in a programmer in order to save time and effort. PHP supports four different loop styles.

  • while – Loops through a code block as long as the given condition is true.
  • do...while – The code block running once and then is tested. State. If the condition is true, the declaration shall be repeated until the condition stated is true.
  • for – Loops via a code block before a given number is reached in the counter.
  • foreach – Loops for each unit of an array across a block of code.

Why to Use Loops?

When trying to recreate code, it might be tedious to retype or copy and paste the same code over and over again. Worse, unintentional mistakes might lead to programme malfunctions.

That’s quite a few keystrokes! What if you decide later that you want to start each statement with “The count is currently: ”? You’d have to copy it and paste it into every single line.

Fortunately, loops are a function in most programming languages that allows you to automatically repeat code before such requirements are met. Iteration is a phrase used to describe the repetition of code, and it refers to each time the code is executed. Loops will reduce the number of lines of code you write while still allowing you to update it later.

PHP is no exception, as it offers a variety of ways to repeat the execution of a code block.

This Article has cover the following PHP loop types:

  • while
  • do … while
  • for
  • foreach

There are conditions in each of these loops that prevent the loop from executing. If these requirements are not met, an endless loop will follow, and the software will never be able to quit executing the code block.

How to use loops in PHP?

In order to write effective code, any programmer needs have a thorough understanding of loops and how to use them effectively in programming.

When writing code, we must always repeat a same set of functions. Performing them one at a time would result in a higher number of lines of code and a longer duration. As a result, the software gets more difficult to understand. As a result, instead of using loops to run the code, we can use them!

Tagged : / / / / / / / / / / / / / /

How to use Link Property in CSS?

When you use the “<a>” tag on your HTML page then show text color automatic blue & underline. If you want to implement in your tag using CSS then implement the below property-

Ex:-

a:link {
color: red;
}

a:hover MUST come after a:link and a:visited

a:active MUST come after a:hover

Tagged : / / / / /

How to use Visibility Property in CSS?

This property is used to specify whether or not an element is visible. We can set this property to visible (default), hidden or collapse.

hidden –

The element is invisible not removed.

collapse-

This value is only used for table elements. collapse removes a row or column, but it does not affect the table layout. The space taken up by the row or column will be available for other content. If collapse is used on other elements, it will be treated as “hidden”.

Ex:-

p { visibility: hidden;}

Hiding an Element with CSS: Display vs Visibility vs Opacity | Magnus Benoni
Tagged : / / / / /

How an element should display in CSS?

This property is used to define how an element should display. Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline.

inlinetable-row-group
blocktable-caption
flextable-column-group
inline-blocktable-header-group
inline-flextable-footer-group
inline-tabletable-cell
list-itemtable-column
run-intable-row
tablenone
p { display: inline; }
How to use the top 5 CSS display values: none, block, inline-block, table,  and flex

Block-level Elements

A Block-level element always starts on a new line and takes up the full width available.

Ex: –

<div>

<h1>

 <p>

Best JavaScript Development Services Provided by Developers

Inline Elements

An inline element does not start on a new line and only takes up as much width as necessary.

Ex: –

<span>

<a>

<img>

The Easy Guide to Building A CSS Image Gallery | Udacity

Display

inline – When we set this value, the element does not start on a new line and only takes up as much width as necessary (we can’t set width/height it won’t work)

block – When we set this value, element always starts on a new line and takes up the full width available (we can set width/height)

inline-block – It is combination of inline and block value. It doesn’t start on new line but we can set width and height.

none – The element will not be displayed at all (has no effect on layout)

flex – Displays an element as a block-level flex container.

inline-flex –  Displays an element as an inline-level flex container.

inline-table – The element is displayed as an inline-level table 

run-in – Displays an element as either block or inline, depending on context

How to use Display?

  • table – It works like a element
  • table-caption – It works like a element
  • table-header-group – It works like a element
  • table-footer-group – It works like a element
  • table-row-group – It works like a element
  • table-cell – It works like a element
  • table-row – It works like a element
  • list-item – It works like a element
Tagged : / / / / /

Tutorials for PHP “Switch Case” Condition

What is “The switch Statement”?

The assertion (Switch) looks like a series of declarations that all say the same thing. To select one of the numerous executable code blocks, use the term (Switch).

switch (n) {
  case label1:
    code to be executed if n=label1;
    break;
  case label2:
    code to be executed if n=label2;
    break;
  case label3:
    code to be executed if n=label3;
    break;
    ...
  default:
    code to be executed if n is different from all labels;
}
PHP Switch - javatpoint

Example1:-

Output:-

Example2:-

Output:-

Example3:-

Output:-

Tagged : / / / / / / / / /