This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:web_development:media:php [2021/12/21 07:54] mag |
en:web_development:media:php [2023/08/16 09:33] (current) |
||
---|---|---|---|
Line 218: | Line 218: | ||
* Here we are replacing the image link with the first item in the photos array, and joining the parts of the string with < | * Here we are replacing the image link with the first item in the photos array, and joining the parts of the string with < | ||
* This works, but there is a cleaner way. Place the following code inside the for loop. | * This works, but there is a cleaner way. Place the following code inside the for loop. | ||
+ | < | ||
+ | * When you refresh your page you should see this sentence 6 times exactly as is. That's not what we want. Let's change it a bit. | ||
< | < | ||
- | * When you refresh your page you should see this sentence 6 times with the numbers 0 to 5. So the variable | + | * Now when you refresh your page you should see the sentence 6 times with the numbers 0 to 5, which is much better. |
+ | * So wrapping | ||
+ | * Let's try that with the array item. | ||
+ | < | ||
+ | * Refresh the page and see that we now see the string. | ||
+ | * Let's change this to the HTML for our image. | ||
+ | < | ||
+ | * Refresh the page and you should now see your photos displayed properly. | ||
+ | * We could stop here, but I want to take it one step further. | ||
+ | * In your page, right click and select 'View Page Source' | ||
+ | * Notice how most of the page is readable, but the code generated by PHP (the list of images inside < | ||
+ | < | ||
+ | * Refresh your page and check the source code again. Now it's much better. | ||
+ | * We've added < | ||
+ | * Now you're ready to practise. | ||
- | + | [[en: | |
- | * Now let's add the image code to our generated HTML. Replace your error log with the following code. | + | |
- | < | + | |
- | * When you refresh your page now, you should see the images in the album container again. | + | |
- | * This code may look complicated, | + | |
- | * < | + | |
- | * We can set text by either < | + | |
- | * If we use < | + | |
- | * Using double quotes also allows processing of ' | + | |
- | * The last thing to notice is that we've changed the < | + | |
- | + | ||
- | [[en: | + |