Jump to content

[SOLVED] Cannot point filepath to correct directory


Maracles

Recommended Posts

Hi,

 

I'm following some examples in a book and executing the following code below and having a small issue. Earlier in the code I have created the $pictures array. My problem is that this example relies on the .jpg files being in the same directory as the .php file, however I want the images to be in a subfolder called '\images'. How do I point to this subfolder? I think it must simply be altering the HTML being echoed but nothing I try works.

 

<h1>Bob's Auto Parts</h1>
<div align="center">
<table width = 100%>
<tr>

<?php
  
  for ($i = 0; $i < 3; $i++) {
    echo "<td align=\"center\"><img src=\"";
echo $pictures[$i];
echo "\"/></td>"; 
  }
?>
</tr>
</table>
</div>
</body> 

 

 

 

Link to comment
Share on other sites

That's great, it worked.

 

What is the difference between using ' instead of " when printing the HTML? I noticed you used this method instead of that chosen in the book.

 

Also, as you can see in the code I posted the book recommended breaking the HTML up using \, however it never really explained why, what does this do?

 

Thanks for the help!

Link to comment
Share on other sites

you have three methods of declaring a string - single quotes, double quotes and the heredoc syntax.

 

if you you use double quotes then you have to escape any double quotes in your string - I just used single quote so you didn't have to do any escaping...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.