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> 

 

 

 

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!

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.