TAILIEUCHUNG - Professional Information Technology-Programming Book part 63

Tham khảo tài liệu 'professional information technology-programming book part 63', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Summary In this lesson you have learned how variables work in PHP. In the next lesson you will see how to use conditional and looping statements to control the flow of your script. Lesson 3. Flow Control In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script. In this chapter we ll look at two types of flow control conditional statements which tell your script to execute a section of code only if certain criteria are met and loops which indicate a block of code that is to be repeated a number of times. Conditional Statements A conditional statement in PHP begins with the keyword i f followed by a condition in parentheses. The following example checks whether the value of the variable number is less than 10 and the echo statement displays its message only if this is the case Snumber 5 if Snumber 10 echo Snumber is less than ten The condition number 10 is satisfied if the value on the left of the symbol is smaller than the value on the right. If this condition holds true then the code in the following set of braces will be executed otherwise the script jumps to the next statement after the closing brace. Boolean Values Every conditional expression evaluates to a Boolean value and an if statement simply acts on a trUE or FALSE value to determine whether the next block of code should be executed. Any zero value in PHP is considered FALSE and any nonzero value is considered trUE. As it stands the previous example will be trUE because 5 is less than 10 so the statement in braces is executed and the corresponding output is displayed. Now if you change the initial value of number to 10 or higher and rerun the script the condition fails and no output is produced. Braces are used in PHP to group blocks of code together. In a conditional statement they surround the section of code that is to be executed if the preceding condition is true. Brackets and Braces You will come across three types of brackets when

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.