tailieunhanh - Publishing AJAX and PHP - part 10

Lỗi có thể xảy ra ở phía khách hàng, hoặc ở phía máy chủ. Chúng tôi đã nỗ lực để có các khách hàng được bảo vệ bằng cách thực hiện một thử / bắt cơ chế trong phần chính của mã này. Mặt khác, khi lỗi xảy ra trên máy chủ, mà lỗi không tuyên truyền cho khách hàng như là một lỗi khách hàng. | Server-Side Techniques with PHP and MySQL Errors can happen on the client side or on the server side. We made efforts to have the client protected by implementing a try catch mechanism in key portions of the code. On the other hand when an error happens on the server that error doesn t propagate to the client as a client error. Instead on the client we must manually analyze the input received from the server and if it doesn t look like what we expected we generate an error manually using throw. If the di splay_errors setting in is set to Off when a PHP parse or fatal error happens the error is logged only to the Apache error log file Apache logs and the script s output will be void. So if we receive a void response we also assume that something bad happened on the server and we build a generic error message on the client. For example if you try to load the page when no internet connection is available so the remote server isn t reachable then it should result in the following error being displayed the error message will look differently if display_errors is set to Off in Figure An Error Message When No Internet Connection is Available The code in proxyping .php simply uses the parameters received though get to access the random number generator server. One interesting detail to note in this script is the way we set the page expiration headers. Setting page expiration is important because the server is always called using the same URL and query string and the client browser may decide to cache the result and we don t want that because the results wouldn t be exactly random any more. php load the error handling module require_once make sure the user s browser doesn t cache the result header Expires Wed 23 Dec 1980 00 30 00 GMT header Last-Modified . gmdate D d M Y H i s . GMT header Cache-Control no-cache must-revalidate header Pragma no-cache You can find an excellent article on page caching and PHP at http .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.