Jump to content

capturing echo from another page HElp!!


Recommended Posts

Hey guys,


I m not an expert in PHP but i want to learn php now. :)


So the question is,


So i have 2 machines that I want to communicate; let's say and


And then, there is a php called test_main.php in, then test.php in


My goal is to call test.php and then capture the echo result... is it possible?


kinda like:

in test_main.php

echo file_get_contents("");


in test.php

echo "HELLO WORLD!";


so the output when i call test_main.php is "HELLO WORLD!"


Thanks guys! Appreciate it


P.S. Maybe the function that I m using is incorrect? Please let me know of another function to use?

Link to comment
Share on other sites

There are a few different ways to achieve this, each with their own pros and cons depending on what you want to do with the file.


If you are just looking to grab the OUTPUT of the PHP script, I would recommend using fopen() to open the file, and then readfile() to load the output of the file into a variable.  This, also, assumed that you have allow_url_fopen enabled on your system.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

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

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.