Jump to content

Reading the output of an evaluated PHP file


m1tch37

Recommended Posts

I have a php script located on my server which when viewed has a simple text output, but contains a huge amount of processing.

 

I am trying to read this text output from another page, however, fread, file and file_get_contents all return the PHP code, not the evaluated output. I suppose this makes sense, its just reading the file, but how can I read what you see in a web browser?

 

I can't directly include the file because both are big scripts that are very different, but have many similar variable names. When I include one into another it makes a storm of errors.

 

How can I get around this, by either reading an evaluated php file on my server, or somehow including a page whilst keeping it completely independent besides a string I must read?

 

Thanks.

 

Edit: If i explained it poorly, here is an example:

 

toread.php:

<?php print "sunny"; ?>

 

index.php:

<?php print "The weather is ".file_get_contents("toread.php"); ?>

 

Expected (desired) Results:

The weather is sunny

 

Actual Results:

The weather is <?php print "sunny"; ?>

I can't directly include the file because both are big scripts that are very different, but have many similar variable names. When I include one into another it makes a storm of errors

 

I can't use include, the example I had was simplified.

 

Whilst not the most elegant solution, I made do with reading the file off the server as you suggested. It shall do for this rough hack.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.