Proper Format of iframe in PHP?

You are not properly escaping the double quotes. You only escape it before the http:// bit and all the way at the end, but not in between (which is also necessary). If you encapsulate the HTML between single quotes, you don’t have to escape all the double ones. Try it like this:

echo '<li><iframe src="http://localhost/ptb1/includes/mod_uploads/profile_pics/index.php" width="188" height="258" scrolling="no" style="overflow:hidden; margin-top:-4px; margin-left:-4px; border:none;"></iframe></li>';

Although, you’re not using any variables in your string, so alternatively you can also “step out” of PHP for a bit and just use plain HTML, like:

<?php
// Your code starts here somehwere, now close the PHP tag
?>
<li><iframe src="http://localhost/ptb1/includes/mod_uploads/profile_pics/index.php" width="188" height="258" scrolling="no" style="overflow:hidden; margin-top:-4px; margin-left:-4px; border:none;"></iframe></li>
<?php
// ... and continue right here

Leave a Comment