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"; ?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.