MySQL /PHP Database Applications Second Edition phần 3

Chúng tôi sẽ xem xét cả hai loại breakpoint trong chương này, nhưng có thể bạn sẽ sử dụng rất nhiều cựu nhiều hơn sau này. nhất Hình 15-1. Cửa sổ trình gỡ lỗi thực sự là một giao diện GDB chương trình dòng lệnh, đó là các trình gỡ lỗi được sử dụng bởi Xcode | Chapter 5 Control Structures IN THIS CHAPTER Understanding the syntax of if statements Determining true and false values with PHP Learning PHP loops Choosing loops to use in your scripts Control structures are the building blocks of programming languages. PHP has all the control structures needed to make a language work. If you re familiar with C or Perl none of the features we discuss in this chapter should come as much of a surprise. However if you re approaching PHP from a background in VBScript or Visual Basic the syntax will probably be different from what you re used to. If you aren t familiar with functions you might want to peek ahead to the beginning of the next chapter for a quick overview but come right back If you find the syntax to be a little heavy at first stick with it. You might find that the extra brackets and parentheses actually help you write readable code. The if Statement The if statement is pretty much the cornerstone of all programming languages. In PHP an if statement typically takes this basic form if condition or set of conditions actions to perform if condition is true. After the word if is a set of parentheses. Within those parentheses is the single condition or set of conditions to be tested. If the condition is evaluated as being true the code within the curly braces will execute. The following will test true and print I m True to a Web page. 117 118 Part 11 Working with PHP php foo 100 bar 10 if foo bar echo I m True This is clear enough. But before we mention the complexities of the if statement you should know how PHP determines whether a condition is true or false. Determining true or false in PHP The next section shows the operators commonly used in if statements. These are fairly easy to understand. In the preceding code example 100 is greater than 10 so foo bar will test true. No problem. But there s a bit more to these tests in PHP. The words TRUE and FALSE also carry the expected meanings. if TRUE echo Yup this will be .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
1    282    4    02-07-2024
Đã 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.