TAILIEUCHUNG - Object-Oriented Programming with PHP 5 phần 5

để giảm sự đau đớn của OOP trong một số trường hợp. Hai trong số các phương pháp ma thuật được giới thiệu để thiết lập và nhận được giá trị tài sản năng động trong một lớp học. Bây giờ chúng ta hãy xem các mã trong hành động. Sử dụng lớp trên với kịch bản sau đây: | More OOP This will install memcached as a service. memcached -d start This will start the daemon service. Now it s time to store some objects into the memcached server and retrieve it. memcache new Memcache memcache- connect localhost 11211 or die Could not connect tmp_object new stdClass tmp_object- str_attr test tmp_object- int_attr 12364 memcache- set obj tmp_object false 60 5 or die Failed to save data at the server When you execute the code above the memcache server saves the object tmp_object against the key obj for five minutes. After five minutes this object will not exist. By this time if you need to restore that object you can execute the following code memcache new Memcache memcache- connect localhost 11211 or die Could not connect newobj memcache- get obj That s it. Memcache is so popular that it has Perl Python Ruby Java and Dot Net and C port. Summary In this chapter we learned how to use some advanced OOP concepts in PHP. We learned how to retrieve information from any object and learned about ArrayAccess ArrayObject Iterators and some other native objects which simplifies the life of a developer. Another very important thing we learned from this chapter is Exception Handling. In next chapter we will learn about design patterns and how to use them in PHP. Untill then happy exploring. 66 Design Patterns Object oriented programming was basically introduced to ease the development process as well as reduce the time of development by reducing amounts of code. If properly planned and designed OOP can increase the performance of the program to a great extent. One of those magical performance cum code reduction issues is Design Pattern which was introduced by Eric Gamma and his three other friends in the book Design Patterns in 1972. Because of four authors the book was introduced as written by Gang of Four or simply Goff. In that legendary book Gang of Four introduced several patterns to minimize the amount of code as well as to introduce effective coding

TỪ KHÓA LIÊN QUAN
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.