PDA

View Full Version : PHP Including Problems



Surya
02-17-2006, 11:13 AM
Thread Deleted

Twey
02-17-2006, 11:17 AM
Because you have two HTML documents, one inside the other. You need to use an output buffer to extract the contents of the body from the page you include.

Surya
02-19-2006, 12:20 PM
How to do it output buffer, sorry can u explain in detail pls...

Twey
02-19-2006, 12:27 PM
<?php
ob_start();
include("../music/andromeda.php");
$page = ob_get_contents();
ob_end_clean();
$page = explode($page, "body>")[1];
$page = substr($page, 0, strlen($page) - 2);
echo($page);
?>Make sure you don't have any important scripts in the head, because they'll get stripped.

Surya
02-19-2006, 12:35 PM
Thread Deleted

Twey
02-19-2006, 12:39 PM
Sorry, you're right.
<?php
ob_start();
include("../music/andromeda.php");
$page = ob_get_contents();
ob_end_clean();
$page = explode("body>", $page);
$page = $page[1];
$page = substr($page, 0, strlen($page) - 2);
echo($page);
?>

Surya
02-19-2006, 12:41 PM
Thread Deleted

Twey
02-19-2006, 12:41 PM
See the post.

Surya
02-19-2006, 12:43 PM
Is there any solution to include???

:confused: :confused: :confused:

Twey
02-19-2006, 12:57 PM
... what? I just gave you one...

Twey
02-19-2006, 03:46 PM
OK... let's try this.
<?php
ob_start();
include("../music/andromeda.php");
$page = ob_get_contents();
ob_end_clean();
$page = explode("<body", $page);
$page = $page[1];
$page = explode(">", $page);
$page = $page[1];
$page = explode("</body>", $page);
$page = $page[0];
echo($page);
?>
Regex would be much more elegant here, but PHP seems to have a problem with character classes I can't quite understand.

Surya
02-19-2006, 05:38 PM
the last code you gave me, shows only a blanc page....:confused: :confused:


What is Regex??