Page 1 of 1

Including whole php pages within a php page.

Posted: Tue Jan 25, 2005 11:36 am
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

Posted: Tue Jan 25, 2005 11:45 am
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.

Posted: Tue Jan 25, 2005 1:50 pm
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?

Posted: Tue Jan 25, 2005 2:00 pm
by feyd
the preg_* functions (regular expressions) are what I recommend for extracting data.

Posted: Tue Jan 25, 2005 2:38 pm
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.

Posted: Tue Jan 25, 2005 2:53 pm
by LizzyD
thanks very much for the advice guys. i'll check it all out now!

lizzyd