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