External 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
insane
Forum Newbie
Posts: 5
Joined: Wed Mar 24, 2004 3:56 am

External page

Post by insane »

Howzit ppl

This might be a dumb question but I'm trying to make the result of a page a variable, say for example this external page's name is page.php and the other page with the main code that i'm working on is called help.php. Here is an example of what I think it must look like but I know its wrong. I hope this gives you an idea of what I'm tying to do

<?php //this page is called help.php

$myvariable = (page.php)

echo ("$myvariable")

?>

You will notice that (page.php) is where I want the external page (almost like a .css page) to be included as a variable.

Any Ideas?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You could use output buffering to do it.

Code: Select all

ob_start();
require_once 'page.php';
$myvariable = ob_get_contents();
ob_end_clean();
echo $myvariable;
(though i'm not sure why you'de want to contents of a php file in a variable ;))
insane
Forum Newbie
Posts: 5
Joined: Wed Mar 24, 2004 3:56 am

Post by insane »

thanx i'll give it a try :lol:
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

hey! lets say page.php was a page that output a pdf file - could I use this to send that as an attachment in a mime email?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Sure.
Post Reply