Click here to Skip to main content
15,173,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi , I need to display html source code of a url , how can i get it .

I need raw html code like this :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head id="Head1"><title>


I used it :
<?php  $data = file_get_contents("",0);
echo $data;

But It was not getting Source code ,

Any help is appreciated !
Updated 29-Nov-14 0:17am
Zoltán Zörgő 29-Nov-14 7:16am
What have you got than?
Srinivas08 29-Nov-14 8:37am
simply all that html page itself was duplicated in my webpage

$data = file_get_contents('');
echo htmlspecialchars($data);
Try this:
<?php  $data = file_get_contents("");
$html_encoded = htmlentities($data);
echo $html_encoded;
thanks , Now its working ... I am getting html source code as output !
Peter Leow 29-Nov-14 20:37pm
This is not a solution, should remove it. You can acknowledge the right solution by using the "Have a Question or Comment?" button. Do not forget to accept the right solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900