PHP in Action phần 3

Thay thế được xây dựng trong PHP lỗi gây tử vong với các trường hợp ngoại lệ Một khi chúng ta đang sử dụng các trường hợp ngoại lệ, đó là một khó chịu chút lỗi này PHP được báo cáo như PHP 4 phong cách lỗi chứ không phải là trường hợp ngoại lệ. | class Document. function getSummary preg_match A. . this- body m return array_shift m This is the kind of small adjustment to the data that might give objects value even in simple applications. Another example is outputting a date in different formats. But the real benefits of using domain objects are realized when they embody business rules or business logic. For example an e-commerce system might need to calculate prices using discounts based on varying criteria including the kind of product the season and the type of customer. Domain objects are also useful for expressing complex relationships. An example might be a tree structure such as a discussion forum with expandable collapsible threads. A moderately simple web application might have relatively little use for advanced domain objects. But the rest of the application can still benefit from using objects. Both database access and user interaction can gain from using object-oriented techniques. These objects have even less of a resemblance to real objects. Some of them might represent fragments of what the user sees in the application but often the objects are engines that process organize or move data around. Template engines described in detail in chapter 13 are an interesting example. In the section on the Adapter design pattern in chapter 7 we will see the difference between the objects used by two popular PHP template engines Smarty and PHPTAL. PHPTAL objects represent something almost real or at least familiar to anyone with experience of PHP web programming a template containing HTML markup. A Smarty object on the other hand is an engine that can process any template. You feed the Smarty object a template and it generates the HTML output. Other types of objects that are commonly used in web programming are controllers and filters to process and interpret user input and objects that transform and move data into and out of a database. Summary Object orientation helps make complex programs more .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.