TAILIEUCHUNG - Học php, mysql và javascript - p 9

CHAPTER 4 Expressions and Control Flow in PHP The previous chapter introduced several topics in passing that this chapter covers more fully, such as making choices (branching) and creating complex expressions. In the previous chapter, I wanted to focus on the most basic syntax and operations in PHP, but I couldn’t avoid touching on more advanced topics. Now I can fill in the background that you need to use these powerful PHP features properly. In this chapter, you will get a thorough grounding in how PHP programming works in practice and how to control the flow of the program. Expressions Let’s start with the. | CHAPTER 4 Expressions and Control Flow in PHP The previous chapter introduced several topics in passing that this chapter covers more fully such as making choices branching and creating complex expressions. In the previous chapter I wanted to focus on the most basic syntax and operations in PHP but I couldn t avoid touching on more advanced topics. Now I can fill in the background that you need to use these powerful PHP features properly. In this chapter you will get a thorough grounding in how PHP programming works in practice and how to control the flow of the program. Expressions Let s start with the most fundamental part of any programming language expressions. An expression is a combination of values variables operators and functions that results in a value. It s familiar to anyone who has taken elementary-school algebra y 3 abs 2x 4 which in PHP would be y 3 abs 2 x 4 The value returned y or y in this case can be a number a string or a Boolean value named after George Boole a nineteenth-century English mathematician and philosopher . By now you should be familiar with the first two value types but I ll explain the third. A basic Boolean value can be either TRUE or FALSE. For example the expression 20 9 20 is greater than 9 is TRUE and the expression 5 6 5 is equal to 6 is FALSE. Boolean operations can be combined using operators such as AND OR and XOR which are covered later in this chapter. Note that I am using uppercase letters for the names TRUE and FALSE. This is because they are predefined constants in PHP. You can also use the lowercase versions if you prefer as they are also predefined. In fact the lowercase versions are more stable 61 because PHP does not allow you to redefine them the uppercase ones may be redefined something you should bear in mind if you import third-party code. Example 4-1 shows some simple expressions the two I just mentioned plus a couple more. For each line it prints out a letter between a and d followed by a colon and the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.