TAILIEUCHUNG - Professional Information Technology-Programming Book part 66

Tham khảo tài liệu 'professional information technology-programming book part 66', 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 to use functions to modularize your code. In the next lesson you will learn about ways to work with numeric data in PHP. Lesson 5. Working with Numbers In this lesson you will learn about some of the numeric manipulations you can perform in PHP. Arithmetic As you would expect PHP includes all the basic arithmetic operators. If you have not used another programming language the symbols used might not all be obvious so we ll quickly run through the basic rules of arithmetic in PHP. Arithmetic Operators Addition is performed with the plus symbol . This example adds 6 and 12 together and displays the result echo 6 12 Subtraction is performed with the minus symbol - which is also used as a hyphen. This example subtracts 5 from 24 echo 24 - 5 The minus symbol can also be used to negate a number for example 20 . Multiplication is performed with the asterisk symbol . This example displays the product of 4 and 9 echo 4 9 Division is performed with the forward slash symbol . This example divides 48 by 12 echo 48 12 Division When you divide two integers the result is an integer if it divides exactly. Otherwise it is a double. A fractional result is not rounded to an integer. Modulus is performed by using the percent symbol . This example displays 3the remainder of 21 divided by 6 echo 21 6 Modulus The modulus operator can be used to test whether a number is odd or even by using number 2. The result will be 0 for all even numbers and 1 for all odd numbers because any odd number divided by 2 has a remainder of 1 . Incrementing and Decrementing In PHP you can increment or decrement a number by using a double plus or double minus -- symbol. The following statements both add one to number number number The operator can be placed on either side of a variable and its position determines at what point the increment takes place. This statement subtracts one from countdown before displaying the result echo -- countdown However the following .

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.