This article is to describe how to include a page from other web site to our php page.
php include url is not so simple as include a file in your site. We can edit web pages by including it to our php page.
php include external url is not use include() or require() methods of php , which are used for local inclusion of pages in our site.
If we want to use that we may use allow_url_include php for that.
Here I am using file_get_contents() for this purpose.
Code
Here I am including the Gmail home page. So give the URL ' http://www.gmail.com ' as
parameter to file_get_contents() . The return value from this is stored to the variable
$cnt. Then print this using echo statement.
Hence the Gmail page is displayed just like my local html page. Then I include a <div> in which a message 'Successfully included By Sukesh B R' is displayed.I have use little css to display it in the top of gmail page.
Here is a sample screenshot of this page :-
You can add javascript blocks to this page and access the elements of Gmail home page and make changes in it with your like.You can add any other webpages just like this.
You can also read:- Download image file using PHP
Thanks for reading this article. Please just tick a response in the Reactions check boxes provided
under this .
php include url is not so simple as include a file in your site. We can edit web pages by including it to our php page.
php include external url is not use include() or require() methods of php , which are used for local inclusion of pages in our site.
If we want to use that we may use allow_url_include php for that.
Here I am using file_get_contents() for this purpose.
Code
<?php
$cnt=file_get_contents('http://www.gmail.com');
echo $cnt;
echo "<div style=\" position:absolute;left:150px;top:50px \">
<h1 style=\"color:red\">Successfully included By Sukesh B R
</h1></div>";
?>
$cnt=file_get_contents('http://www.gmail.com');
echo $cnt;
echo "<div style=\" position:absolute;left:150px;top:50px \">
<h1 style=\"color:red\">Successfully included By Sukesh B R
</h1></div>";
?>
Here I am including the Gmail home page. So give the URL ' http://www.gmail.com ' as
parameter to file_get_contents() . The return value from this is stored to the variable
$cnt. Then print this using echo statement.
Hence the Gmail page is displayed just like my local html page. Then I include a <div> in which a message 'Successfully included By Sukesh B R' is displayed.I have use little css to display it in the top of gmail page.
Here is a sample screenshot of this page :-
You can add javascript blocks to this page and access the elements of Gmail home page and make changes in it with your like.You can add any other webpages just like this.
You can also read:- Download image file using PHP
Thanks for reading this article. Please just tick a response in the Reactions check boxes provided
under this .