Aps18
Aps18

Reputation: 441

Echoing html file using php

<html>
<body>
<?php
$html='<html>
<body>
<p>
Illustrating wget -r , with images too  
</p>
<p>
This is the first image
    <img src="abc.JPG" alt="First Captured Image"/>
</p>
<p>
This is the second image
<img src="def.JPG" alt="Second Captured Image"/>
</p>
</body>
</html>'; 
echo($html);
$dom = new domDocument;
@$dom->loadHTML($html);

$dom->preserveWhiteSpace = false;
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
echo $image->getAttribute('src');
echo $alter->get Attribute('alt');
echo "<img sr='$image'/>";  
}

</body>
</html>

My code is to parse the images in the html code above and then use php to echo it again. This is my sample code. How do I echo the above html code, using php, and display in the same way?

I tried doing this, but I cant place image in exactly the same position as where I retrieved. I don't want to use "header(contents)"

Upvotes: 0

Views: 106

Answers (1)

Shaikh Farooque
Shaikh Farooque

Reputation: 2630

Your statement echo "<img sr='$image'/>"; is incorrect. The correct one is

echo "<img src='$image'/>";  

Upvotes: 1

Related Questions