The While Loop

php-training-in-gurgaon
A While loop is used when we have to repeat a set of statements as long as the condition is false. It could be the best where number of repetition is not known earlier or in advance. It can be explain in plain English as "Keep doing something until a condition is true". Syntax: while (condition) { //  Set of statements goes here; } Example <?php $ct=5; while($ct<=50) { echo  $ct . "<br>"; $ct = $ct+5; } ?> Output: 5 10 15 20 25 30 35 40 45 50 The do…while loop example: <?php $i = 1; do { $i++; echo  $i . "<br>"; } while($i <= 3); ?>  Output: 2 3 4 Difference Between while and do…while Loop: With a while loop, the condition to be evaluated is tested…
Read More

The For Loop

php-training-in-gurgaon
PHP for loop can be used to traverse set of code for the specified number of times. For example if you want to repeat something ten or twenty times. It should be used if number of iteration is known otherwise I recommend you to use while loop. Syntax: for (Initialization; Condition; Progressive) { //set of statements to be executed; } Parameters: Initialization: Initialize the loop counter value Condition: Check for condition. If it evaluates to TRUE, the loop continues. If FALSE then the loop ends. Progressive: Increase / Decrease the loop counter value Example: for($var=1; $var<=20; $var=$var+1) { echo $var ." "; } Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example: to display 1st 20 natural…
Read More

Arrays in PHP

php-training-in-gurgaon
An array is a data structure that stores similar type of values in a common variable. Arrays are also called homogeneous data type. For example if you want to store 50 numbers then instead of defining variables it is easy to define an array with size of 50. In PHP, the array() function is used to create an array Arrays can store numbers, strings and any object but their index will be represented by numbers. By default array index starts from zero. $x=array("laxmi","hirdesh","rahim","ashu","amit"); // To count number of elements stored in array x echo count($x); // To populate value from any specific index or position //echo $x[1]; // output – Hirdesh // To print all elements in array x - using for-each loop echo " <br>Names are :"; foreach ($x…
Read More
PHP Ajax Tutorial

PHP Ajax Tutorial

php-training-in-gurgaon
The Ajax provides two way to developers to build rich application, server centric and client centric. The extenders use a block of JavaScript code to add new enhanced capabilities to ASP.net. JQUERY is the library of JavaScript. It is lightweight, supported by all the browser, active developer community, and extensible plug-in to develop the website. Using jqurey we can do DOM manipulation, apply CSS to the element, CURD operation on the element, and apply CSS runtime AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. Ajax uses the JavaScript DOM, the XMLHttpRequest object, XML, and CSS to download and display just the content that needs to change. Ajax allows content on Web pages to update immediately when a user…
Read More