When we executing this program on browser it prints first value of initialized value when it first execution in for loop it initialized and condition checks then body of code will work after that execution only do another step of increment then condition checks and body code will work it same as working till condition fails. When work with php we need to create and process php files at server location and then we need to start the server before execute the program. In conclusion we are able to know how to covert stdclass object to array using php. This loop needs to work till number ‘10’ so we gives condition as upto ‘$i for after each time value printed it points next line so output will looks clear otherwise we can’t see clearly. Now we can get some idea about our program, variable $i to value ‘1’ defines we need to print from number ‘1’ so we initialized from ‘1’.For loop syntax is, for(variable_name=start value variable_name condition end value variable increament).First we need to create for loop with one variable here declared variable ‘$i’ with value ‘1’ and ‘$’ symbol must add before variable name when we define a variable in php.The default file extension for php files is “.php” and php statements end with ‘ ’ semicolon.A php script can be placed anywhere in the document.Same as other loop also but the syntax only vary. Steps are repeated till exit condition comes. If statement is true, then loop body is executed and loop variable gets updated. First initialize this loop variable to some value, then check whether this variable is less than or greater than counter value. Here we used for loop that means a loop variable is used to control the loop. Step By Step Guide On Print 1 To 10 Using For Loop In PHP :. In loop always have number of executions available till condition fails, increment steps and some body of codes. Here we need to use for loop for printing numbers from one to ten. When we have to code same process till some condition we can move with loops otherwise it takes too much time, space of code and had complexities. In this tutorial we will show you the solution of print 1 to 10 using for loop in PHP, when printing more than two values as we know we have to use loop functions, in php for(), foreach() and while(), etc., are available.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |