I'm trying to load content to an HTML page using PHP files. I've done this successfully using the echo
statement. The issue I am running into now is using full URL's that sit within the HTML within the echo
statement - whenever the PHP file sees two backslashes //
it starts to comment out the code for that line, then seems to ignore the rest of the HTML as part of the echo
How can I use this PHP file to successfully load HTML content that contains URLs? See below for a code reference.
<?php
echo "
<div class="footer">
<!-- ***** Social media icons ***** -->
<div class="socialIcons">
<ul>
<li><a href="http://www.twitter.com/" title="Twitter"><img src="./design/twitter.jpg" alt="My Twitter" /></a></li>
<li><a href="http://www.pinterest.com/" title="Pinterest"><img src="./design/pinterest.jpg" alt="My Pinterest" /></a></li>
<li><a href="http://www.linkedin.com/" title="LinkedIn"><img src="./design/linkedin.jpg" alt="Me on LinkedIn" /></a></li>
</ul>
</div>
<ul>
<li><a href="javascript:void(0)">Contact</a></li>
<li><a href="javascript:void(0)">About</a></li>
<li><a href="javascript:void(0)">Privacy</a></li>
</ul>
</div>
"
?>
Comment: That's because you are using "
to start the echo and then using "
again to assign the parameters to the elements.
<?php
echo '
<div class="footer">
<!-- ***** Social media icons ***** -->
<div class="socialIcons">
<ul>
<li>
<a href="http://www.twitter.com/" title="Twitter">
<img src="./design/twitter.jpg" alt="My Twitter" />
</a>
</li>
<li>
<a href="http://www.pinterest.com/" title="Pinterest">
<img src="./design/pinterest.jpg" alt="My Pinterest" />
</a>
</li>
<li>
<a href="http://www.linkedin.com/" title="LinkedIn">
<img src="./design/linkedin.jpg" alt="Me on LinkedIn" />
</a>
</li>
</ul>
</div>
<ul>
<li>
<a href="javascript:void(0)">Contact</a>
</li>
<li>
<a href="javascript:void(0)">About</a>
</li>
<li>
<a href="javascript:void(0)">Privacy</a>
</li>
</ul>
</div>
';
?>
Change the echo
initial and final "
to '
. Problem solved.
you use the wrong "" charakters. at the beginning you user "" all in "" have to be this ' '.