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 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 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 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 or in the images folder. Reload 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 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 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 like this php if isset imageSize div id pictureWrapper 91 CHAPTER 4 Download from Wow eBook 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 and in the ch04 folder. Preventing errors with include files Many hosting companies turn off error