Đang chuẩn bị liên kết để tải về tài liệu:
Giải pháp thiết kế web động với PHP - p 12

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

LIGHTENING YOUR WORKLOAD WITH INCLUDES Figure 4-12. The ugly gap is removed by creating a style rule directly related to the image size. If the caption still protrudes, make sure there s no gap between the closing PHP tag and px in the block. CSS does not permit whitespace between the value and unit of measurement. 8. The code in random_image.php and the code you have just inserted prevent errors if the selected image can t be found, but the code that displays the image is devoid of similar checks. Temporarily change the name of one of the images, either in random_image.php or. | LIGHTENING YOUR WORKLOAD WITH INCLUDES Figure 4-12. The ugly gap is removed by creating a style rule directly related to the image size. If the caption still protrudes make sure there s no gap between the closing PHP tag and px in the style block. CSS does not permit whitespace between the value and unit of measurement. 8. The code in random_image.php and the code you have just inserted prevent errors if the selected image can t be found but the code that displays the image is devoid of similar checks. Temporarily change the name of one of the images either in random_image.php or in the images folder. Reload index.php several times. Eventually you should see an error message like that in Figure 4-13. It looks very unprofessional. _ Random image iotiee Undefined variable imageSize in C xampp htdocs phpsols index.php on line 30 Monk begging for alms in Kyoto lit enim ad minim veniam quis nostrud exercitation consectetur adipisicing elit. Velit esse Figure 4-13. An error in an include file can destroy the look of your page. 9. The conditional statement at the foot of random_image.php sets imageSize only if the selected image both exists and is readable so if imageSize has been set you know it s all systems go. Add the opening and closing blocks of a conditional statement around the div that displays the image in index.php like this php if isset imageSize div id pictureWrapper 91 CHAPTER 4 Download from Wow eBook www.wowebook.com img src php echo selectedImage alt Random image class picBorder php echo imageSize 3 p id caption php echo caption p div php Images that exist will display normally but you ll avoid any embarrassing error messages in case of a missing or corrupt file a much more professional look. Don t forget to restore the name of the image you changed in the previous step. You can check your code against index_05.php and random_image_02.php in the ch04 folder. Preventing errors with include files Many hosting companies turn off error

Đã 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.