Đang chuẩn bị liên kết để tải về tài liệu:
Phát triển web với PHP và MySQL - p 15

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

String Manipulation and Regular Expressions CHAPTER 4 115 We can adapt the Smart Form example to use regular expressions as follows: if (!eregi(“^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$”, $email)) { echo “That is not a valid email address. Please return to the” .” previous page and try again.”; exit; } $toaddress = “feedback@bobsdomain.com”; // the default value if (eregi(“shop|customer service|retail”, $feedback)) $toaddress = “retail@bobsdomain.com”; else if (eregi(“deliver.*|fulfil.*”, $feedback)) $toaddress = “fulfilment@bobsdomain.com”; else if (eregi(“bill|account”, $feedback)) $toaddress = “accounts@bobsdomain.com”; if (eregi(“bigcustomer\.com”, $email)) $toaddress = “bob@bobsdomain.com”; Replacing Substrings with Regular Expressions You can also use regular expressions to find and replace substrings in the same way as we used str_replace(). The two. | 115 String Manipulation and Regular Expressions Chapter 4 We can adapt the Smart Form example to use regular expressions as follows if eregi A a-zA-Z0-9_ @ a-zA-Z0-9 - . a-zA-Z0-9 - . email echo That is not a valid email address. Please return to the . previous page and try again. exit toaddress feedback@bobsdomain.com the default value if eregi shop customer service retail feedback toaddress retail@bobsdomain.com else if eregi deliver. lfulfil. feedback toaddress fulfilment@bobsdomain.com else if eregi bill account feedback toaddress accounts@bobsdomain.com if eregi bigcustomer .com email toaddress bob@bobsdomain.com Replacing Substrings with Regular Expressions You can also use regular expressions to find and replace substrings in the same way as we used str_replace . The two functions available for this are ereg_replace and eregi_replace . The function ereg_replace has the following prototype string ereg_replace string pattern string replacement string search This function searches for the regular expression pattern in the search string and replaces it with the string replacement. The function eregi_replace is identical but again is not case sensitive. Splitting Strings with Regular Expressions Another useful regular expression function is split which has the following prototype array split string pattern string search int max This function splits the string search into substrings on the regular expression pattern and returns the substrings in an array. The max integer limits the number of items that can go into the array. This can be useful for splitting up domain names or dates. For example domain yallara.cs.rmit.edu.au arr split . domain 4 String Manipulation 116 Using PHP Part I while list key value each arr echo br . value This splits the host name into its five components and prints each on a separate line. Comparison of String Functions and Regular Expression Functions In general the regular expression functions run less efficiently than the string .

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.