Đang chuẩn bị liên kết để tải về tài liệu:
OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P16

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

OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P16:A number of years ago, before I started using PHP, I created dynamic web pages using C. This really wasn’t too different from some of the other options available at the time, though it seems almost unthinkable now. Creating a dynamic page meant outputting HTML from your script and recompiling that script if any changes needed to be made. | interfaces this- OgetInterfaces number count interfaces if number 0 counter 0 description . implements foreach interfaces as i description . i- getName counter if counter number description . return description This code calls a number of self-explanatory inherited methods to build a class description. The only slight complication is that because a class can implement more than one interface O the getInterfaces method returns an array and so requires a foreach loop. When applied to the SoapFault class the following string is returned by the getFullDescription method class SoapFault extends Exception SoapFault is correctly identified as a class rather than an interface it is neither final nor abstract and its derivation from Exception is documented. This is exactly the same description that you saw in Listing 14-1 when you exported this class. Describing Methods and Data Members Since methods are more important than data members let s next deal with how to adapt the reflection classes to document methods. Calling the getMethods method of the Reflectionclass class creates an array of ReflectionMethod objects. The visibility of each method can then be determined by the isPublic isProtected or isPrivate methods of the ReflectionMethod class. However you want to display methods sorted by visibility basically you want a getPublicMethods method and an identical method for displaying private and protected methods. In order to be able to retrieve an array of ReflectionMethod objects sorted by visibility you are going to loop through all the methods in a class and create separate arrays of each type. Let s see how this is done. private function createMethodArrays methods this- getMethods ReflectionMethod array returned foreach methods as m name m- getName if m- isPublic this- publicmethods name m Creating Documentation Using the Reflection Classes 131 if m- isProtected this- protectedmethods name m if m- isPrivate this- privatemethods name m Again the code is quite simple.

TÀI LIỆU LIÊN QUAN
Đã 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.