Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PHP 5/MySQL Programming- P25:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 98 PHP 5 MySQL Programming for the Absolute Beginner head title A simple For Loop title head body h1 A simple for loop h1 for i 0 i 10 i print i br n end for loop body html Each number is printed in the line that looks like this print i br n This line can print only one value but it happens 10 times. The key to this behavior is the for statement. The for structure has three main parts a variable declaration a condition and an increment statement. The n character signifies a newline or carriage return. This means that the program s HTML source code places each number on a separate line. The br tag ensures that the HTML output also places each number on its own line. While carriage returns in the HTML source don t have much to do with how the output looks I like my programs code to be written as carefully as the stuff I build by hand. Initializing a Sentry Variable for loops usually involve an integer non-decimal variable. Sometimes the key variable in a loop is referred to as a sentry variable because it acts like a gatekeeper to the loop. The first part of a for loop definition is a line of code that identifies and initializes the sentry variable to some starting value. In the simple for loop demo the initialization segment looks like this 99 i 0 It specifies that the sentry variable be called i and its starting value be 0. In the Real World You might wonder why the sentry variable is called i. Like most variables it s best if sentry variables have a name that suits their purpose. Sometimes however a for loop sentry is simply an integer and doesn t have any other meaning. In those situations an old programming tradition is often called into play. In the Fortran language one of the earliest common programming languages all integer variables had to begin with the letters i j and a few other characters. Fortran programmers would commonly use i as the name of generic sentry variables. Even though most modern programmers have never written a line of Fortran code the .