TAILIEUCHUNG - Professional Information Technology-Programming Book part 67

Tham khảo tài liệu 'professional information technology-programming book part 67', 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 work with numbers. In the next lesson you will learn all about string handling in PHP. Lesson 6. Working with Strings In this lesson you will learn about some of the powerful string functions that are included in the PHP language. Formatting Strings PHP provides a powerful way of creating formatted strings using the printf and sprintf functions. If you have used this function in C these will be quite familiar to you although the syntax in PHP is a little different. Using printf You use printf to display a formatted string. At its very simplest printf takes a single string argument and behaves the same as echo printf Hello world The power of printf however lies in its ability to substitute values into placeholders in a string. Placeholders are identified by the percent character followed by a format specification character. The following example uses the simple format specifier f to represent a float number. price printf The price is f price The second argument to printf is substituted in place of f so the following output is produced The price is There is actually no limit to the number of substitution arguments in a printf statement as long as there are an equivalent number of placeholders in the string to be displayed. The following example demonstrates this by adding in a string item item The Origin of Species price printf The price of s is f item price Table shows the format characters that can be used with the printf function in PHP to indicate different types of values. Table . printf Format Characters Character Meaning b A binary base 2 number c The ASCII character with the numeric value of the argument d A signed decimal base 10 integer e A number displayed in scientific notation for example 3 u An unsigned decimal integer f A floating-point number o An octal base 8 number s A string x A hexadecimal base 16 number with lowercase letters X A hexadecimal base 16 number with uppercase .

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.