Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Are you trying to manually paste the output of a PHP script into a new PHP script, or do you want a PHP script to generate a new PHP file from itself including that output?

In either case you'd have to escape (particularly the "s), I haven't done PHP in a while, but str_replace() should work nicely for automatically escaping.
 
Well here's the thing. Script 1 is connected to my forum. As new posts are added, it displays them. I want to include the HTML output of Script 1 on my website (located in a different directory).

Is that enough info?
 
Well here's the thing. Script 1 is connected to my forum. As new posts are added, it displays them. I want to include the HTML output of Script 1 on my website (located in a different directory).

Is that enough info?

You could do something like creating a database to share in between where the output is simply stored as a row.

Or you could create a .txt file which both scripts have access to and store the output there.

For this method then both are equally fast, the latter is probably a lot faster to implement. Of course you could do something more complex if you wanted to :)
 
Ugh. That does not sound like fun (I'm a design type after all...)

There's no way to grab the output of a PHP file as if were just an HTML file, eh? Here's the code in the script that grabs the posts (the one I want the output of).

Code:
<?php
// Recent Posts Plugin
// By Rogem
// Version 1.0

define("IN_MYBB", 1);
define("KILL_GLOBALS", 1);
define("NO_ONLINE", 1);

// The Directory to the forum you are using this on. 
// You do not need a beggining or trailing slash
$directory_to_forum = ""; 

require dirname(__FILE__)."/".$directory_to_forum."/global.php";

$plugins->run_hooks("Recent_Posts_Plugin_run");
?>

Of course, this is just the final of a few files.. and some funky database voodoo.
 
Ugh. That does not sound like fun (I'm a design type after all...)

It may not be fun, but it's probably the most direct way to handle your question if I'm understanding it correctly. It's not that bad either. Perhaps you should consider the overall effect you're going for and think of a new direction to solving it. Some times things are hard because you're taking the hard approach ;)
 
It may not be fun, but it's probably the most direct way to handle your question if I'm understanding it correctly. It's not that bad either. Perhaps you should consider the overall effect you're going for and think of a new direction to solving it. Some times things are hard because you're taking the hard approach ;)
Great advice. I had over complicated everything. I ended up writing my own script and everything works great now.

Thank you to everyone for your help.
 
From what I understand, you want one PHP page inside another loaded from different locations. You _can_ pass variables between the two.

If what I'm suggesting is correct, then an include would do fine.

PHP:
<?php
include('path/to/filename.php');
?>
 
And for your information..

The documentation below also applies to require().
The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.