Including whole php pages within a php page.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LizzyD
Forum Newbie
Posts: 22
Joined: Mon Oct 04, 2004 5:36 am

Including whole php pages within a php page.

Post by LizzyD »

hello,

sorry if this is a really stupid question - i've been trying to search for an answer but don't know what the right technical terms are to use.

i have a complete php page, with head tags and body tags etc, and i want to include within this page another complete php with head and body tags etc.

i have tried to accomplish this just using:

Code: Select all

<?php
include ("http://www.includepage.php");
?>
however, this takes ages to load and comes out all messed up.

The only other method i know of that will work is to use frames. However, i don't like frames very much!

Can anyone suggest another solution??

Yours hopefully,

lizzyd
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

is this a remote page? or a local page?

depending on how the output works, you can fetch the file using a file function, such as file_get_contents() which will retrieve the entire file as a string. You can run a regular expression to extract out the body text, or you can just display the page's contents, and leave out yours... it kinda depends on what you want to do with it.
LizzyD
Forum Newbie
Posts: 22
Joined: Mon Oct 04, 2004 5:36 am

Post by LizzyD »

thanks very much for getting back to me feyd. it's a remote page that i'm trying to include - something like this:

https://www.activehotels.com//servlet/x ... anguage=en

thinking about it, i might just need to extract the body contents. is there a function that can achieve this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the preg_* functions (regular expressions) are what I recommend for extracting data.
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

Including external pages has a lot of risks unless it is under your control.

The owner could place malicious code on that page and you happily use it on your site. This should only be done with a lot of care.

As feyd stated you need to clear the body tag and probably css as well. Then clear any script on that page and probably a lot mor I cannot even think off now.
LizzyD
Forum Newbie
Posts: 22
Joined: Mon Oct 04, 2004 5:36 am

Post by LizzyD »

thanks very much for the advice guys. i'll check it all out now!

lizzyd
Post Reply