Jump to content

capturing echo from another page HElp!!


t_mo_t

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 192.168.1.5 and 192.168.1.7

 

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

 

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

 

kinda like:

in test_main.php

<?php
echo file_get_contents("http://192.168.1.7/test.php?test=123123");
?>

 

in test.php

<?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
https://forums.phpfreaks.com/topic/251354-capturing-echo-from-another-page-help/
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.

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.