LIGHTENING YOUR WORKLOAD WITH (Domain and web hosting) INCLUDES and ‘caption’. The

LIGHTENING YOUR WORKLOAD WITH INCLUDES and ‘caption’. The definition of the multidimensional array forms a single state ment, so there are no semicolons until line 19. The closing parenthesis on that line matches the opening one on line 2. All the array elements in between are sepa rated by commas. The deep indenting isn t necessary, but it makes the code a lot easier to read. The variable used to select the image also needs to be changed, because $images[$i] no longer contains a string, but an array. To get the correct filename for the image, you need to use $images[$i][’file’]. The caption for the selected image is contained in $images[$i][’caption’] and stored in a shorter variable. 2. You now need to amend the code in index.php to display the caption like this:

3. Save index.php and random_image.php, and load index.php into a browser. Most images will look fine, but there s an ugly gap to the right of the image of the trainee geisha with a mobile phone, as shown in Figure 4-9. Fortunately, this is easily fixed. Figure 4-9. The long caption shifts the image too far left. 4. Add the following code to random_image.php just before the closing PHP tag: if (file_exists($selectedImage) && is_readable($selectedImage)) { $imageSize = getimagesize($selectedImage); } 109
We recommend high quality webhost to host and run your jsp application: christian web host services.

Leave a Reply