Question:
How do you open a web page from another webpage in PHP?
rfulky
2006-07-26 20:27:48 UTC
What code do I use to open another web page from the web page the user is currently has open.
Four answers:
longhats
2006-07-26 20:32:13 UTC
Don't know coding but seems do me you would create a link. Most software usually has a command to highlight the area and create link.
Hulett H
2006-07-28 00:32:04 UTC
Do you want to output a dynamic link on your site?



">Link







$myvariabletitle" ?>



Are you wanting to forward the user to a different page? (Must be sent before any output is printed.)




header( "Location: http://yahoo.com" );

exit;

?>



or (can be executed after output has already been sent to the browser, but requires javascript or a click)




print '';

print '';

?>



Do you want to read in another web page and output it on your own? (Requires allow_url_fopen to be enabled in the configuration.) Be careful about doing this sort of thing, because if a hundred people hit your page, your server makes one hundred sudden requests to download. If this is the route you're after, look into cacheing/saving the result for a period of time or get fancy and ask the web server if the page has been updated.




$url = "http://www.yahoo.com";

$f = fopen( $url, "r" );

if( !$f ) die( "Could not open $url for reading" );

while( !feof( $f ) ) {

$data = fread( $f, 1024 );



// Print it out

print $data;



// Or store it in a variable

$text .= $data;

}

fclose( $f );

?>



Hope that helps.
fmdeveloper_tim
2006-07-26 20:37:12 UTC
Straight HTML Text would create the link.



If you want to display the page within the page take a look at