Keeper
Keeper

Reputation: 37

Sending data from PHP

I need to 'export' certain information with PHP. However, sending an email won't solve my issue. I also don't want to use PECL functions since the package is not installed by default and I can't know whether it is on the server I'll need to send the information from.

Considering I'm dragging the information from a certain file with a regular expression or whatever and sending it out to an external source. The best scenario would be to write the information to a remote file so that it is publicly easily accessible. I thought of forging a raw socket and appending the data to an additional header but I don't know how that could work. Again, as I said, mail() isn't an alternative in this case.

Any ideas are highly appreciated.

Upvotes: 0

Views: 153

Answers (2)

Lukas Braune
Lukas Braune

Reputation: 61

If you only have little data, you could use file_get_contents() method and append your data URL encoded as parameter to a web resource. The receiver could be a simple PHP script as well.

sender.php

$data_plain = "to be sent";
$data_enc   = urlencode($data);
file_get_contents("https://www.your-receiver.com/receiver.php?data=" . $data_enc);

receiver.php

$data_enc   = $_GET["data"];
$data_plain = urldecode($data_enc);    

Upvotes: 1

sniko
sniko

Reputation: 71

If you want to store it in a variable (and have server side processing done at the same time)

$file = 'some_file.php';
ob_start();
include_once($file);
$contents = ob_get_contents();
ob_end_clean();
echo $contents;

Upvotes: 0

Related Questions