TAILIEUCHUNG - Advanced PHP Programming- P11

Tham khảo tài liệu 'advanced php programming- p11', 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ả | 478 Chapter 20 PHP and Zend Engine Internals opcode 1 Here the ZEND_ASSIGN handler assigns to Register 0 the pointer to hi the value hello. Register 1 is also assigned to but it is never used. Register 1 would be utilized if the assignment were being used in an expression like this if hi hello opcode 2 Here you re-fetch the value of hi now into Register use the op ZEND_FETCH_R because the variable is used in a read-only context. opcode 3 ZEND_ECHO prints the value of Register 2 or more accurately sends it to the output buffering system . echo and print its alias are operations that are built in to PHP itself as opposed to functions that need to be called. opcode 4 ZEND_RETURN is called setting the return value of the script to 1. Even though return is not explicitly called in the script every script contains an implicit return 1 which is executed if the script completes without return being explicitly called. Here is a more complex example php hi hello echo strtoupper hi The intermediate code dump looks similar opnum line opcode op1 op2 result 0 2 ZEND_FETCH_W hi 1 0 1 2 ZEND_ASSIGN 0 hello 1 0 2 3 ZEND_FETCH_R hi 2 3 3 ZEND_SEND_VAR 2 4 3 ZEND_DO_FCALL strtoupper 3 5 3 ZEND_ECHO 3 6 5 ZEND_RETURN 1 Notice the differences between these two scripts. opcode 3 The ZEND_SEND_VAR op pushes a pointer to Register 2 the variable hi onto the argument stack. This argument stack is how the called function receives its arguments. Because the function called here is an internal function implemented in C and not in PHP its operation is completely hidden from PHP. Later you will see how a userspace function receives arguments. opcode 4 The ZEND_DO_FCALL op calls the function strtoupper and indicates that Register 3 is where its return value should be set. Here is an example of a trivial PHP script that implements conditional flow control php i 0 How the Zend Engine Works Opcodes and Op Arrays 479 while i 5 i opnum line opcode op1 op2 result 0 2 ZEND_FETCH_W i 1 0 1 2 .

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.