This code is useful for example if you want to make a script for a links directory and you want to add a frame on top of each page you referrer. Or if you want to make a traffic exchange script and want to add a frame of top of each page loaded on the traffic exchange.
To make this what we do is to call the page that we want to load using fopen() and then printing that page. fopen() is the function used to open files.
In the example below we are giving two parameters http://www.yahoo.com which is the page we want to open and r that indicates that we are opening it for reading.
|
<html>
<head>
<base href="http://www.yahoo.com">
</head>
<body>
<table border=1 width=100%>
<tr>
<td>This is a sample frame</td>
<td><?php
$page = fopen( "http://www.yahoo.com", "r" );
while ( ! feof( $page ))
print fgets( $page, 1024 );
fclose( $page );
?>
</td>
<td>This is a sample frame</td>
</tr>
</table>
</body>
</html> |
The base tag on the head of the page is necessary to make all downloads relative to that page. If we don't use that tag then it's probable that the images will appear broken.