SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Printing number from 1 to 50 by for loop


We can print numbers from 1 to 10 by using for loop. You can easily extend this program to print any numbers from starting from any value and ending on any value.
for( $i=1; $i<=10; $i++ )
{
echo $i;
echo "<br>";
}

The echo command will print the value of $i to the screen. In the next line we have used the same echo command to print one html line break. This way all numbers will be printed in one new line.

You can get more details on for loop here.

Here we have printed from 1 to 10 numbers, by changing the values inside the for loop you can print numbers starting from any value to ending at any value.

For loop is used when we know exactly how many times the looping is required. Here no condition is set for looping. While loops are used for conditional looping.

Let us try with some simple examples.


Further readings
Introduction to PHP: How scripting languages work
PHP beginners guide
echo command & escape character for string outputs
Adding delay to the script execution time by using sleep function
Printing Numbers 1 to 50 to screen
PHP Info: Details on PHP script settings & installation at server end
PHP Version : What is the version of PHP running at the server
Installing PHP on windows server and IIS
Installing PHP5 on windows server and IIS
Setting up PHP in Windows Vista OS to run in IIS7 web server
Configuration of IIS7 to run PHP scripts with ISAPI module












Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Sections
PHP
JavaScript
ASP
HTML
SQL
Photoshop
Articles SEO
PHP Tutorials
Basics
PHP Monthly Planner
PHP Introduction
Loops & structure
Array
Date & Time
Functions
Form Handling
File Handling
Math Functions
String Functions
GD Functions
Comment Posting
Content Management
PHP & Ajax
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.